====== RSA ====== [[/glossaire/rsa|/glossaire/rsa]] Présentations de l'algo RSA: * [[http://www.di-mgt.com.au/rsa_alg.html]] * [[http://www.cryptosec.org/RSA.html]] * key generation * p, q are two large random primes * n = pq is of the required bit length * phi = (p-1)(q-1) * public exponent e: 1 < e < phi, gcd(e, phi) = 1 * secret exponent d: 1 < d < phi, ed ≡ 1 (mod phi) * destroy p, q and phi * public key: n , e * private key: n, d * Encryption: c = me mod n * Decryption: m = cd mod n * Signing: s = md mod n * Signing verification: v = se mod n * Then use advanced schemes: * RSAES-OAEP: (PKCS#1 version 2 and in IEEE P136) The encoding technique involves a Mask Generation Function (MGF) based on a hash function * RSASSA-PSS: The PSS encoding method is used to encode before creating a signature. However, there are active patents associated with this method ===== Divers ===== ==== RSA en Javascript ==== Implémentations RSA (et du BigInt) en Javascript: * [[http://www-cs-students.stanford.edu/~tjw/jsbn/|Tom Wu]] ({{:informatique:javascript-rsa_by_tom_wu.zip|copie locale}}) * qui utilise cette lib: * [[https://github.com/garfieldius/rsa-javascript-php|garfieldius/rsa-javascript-php]] * [[http://ohdave.com/rsa/|Dave Shapiro]] ({{:informatique:javascript-rsa_by_dave_shapiro.zip|copie locale}}) * [[http://www9.atwiki.jp/kurushima/pub/jsrsa/|Kenji Urushima]]: signature RSA depuis certificat x509 , (utilise BigInt et RSA de TomWu). Bench Signature RSA clé 2048 bits: * AMD ATHLON 64 X2 core processor 4200 * FF: 1.872 * **IE: 12.406** * Intel Core i7 M640 2.80GHz * FF: 2.846 * **Chromium: 0.210** * Intel Core2 à 2.40GHz * Firefox: 3.762 * Epiphany: 1.498 Bench Signature RSA clé 1024 bits: * AMD ATHLON 64 X2 core processor 4200 * FF: * IE: * Intel Core i7 M640 2.80GHz * FF: 0.247 * Chromium: 0.038 * Intel Core2 à 2.40GHz * * ==== .Net RSA Parameters ==== RSAParameters Structure ([[http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsaparameters.aspx|msdn]]) ^ RSAParameters field ^ Contains ^ Corresponding PKCS #1 field ^ | D | d, the private exponent | privateExponent | | DP | d mod (p - 1) | exponent1 | | DQ | d mod (q - 1) | exponent2 | | Exponent | e, the public exponent | publicExponent | | InverseQ | (InverseQ)(q) = 1 mod p | coefficient | | Modulus | n | modulus | | P | p | prime1 | | Q | q | prime2 | int dwKeySize = 384 ; bool exportPrivateKey = true ; RSACryptoServiceProvider rsa = new RSACryptoServiceProvider( dwKeySize ); using( StreamWriter sw = new StreamWriter( "RSAParameters.xml" ) ) { sw.Write( rsa.ToXmlString( exportPrivateKey ) ); sw.Close(); } Format .Net System.Security.Cryptography.RSACryptoServiceProvider.ToXmlString() : Private: 3XGodAOyDWfoGGMelpKft1Wx1E15m5yot4Rj0ppWpa/wTaHcudYfl+VIq+0EaC4N AQAB

+dhBWqM/4f1FBB3dP2fqKfhRnsfGqgTz

4uZIM7QCetizjB9PGLoLcLIM2f1vDcD/ U2mXqCMImPJtsEooK5sN2qVE2rXn5atx xblS9etJte+dFuA5txx4163w0Q2udtfV 3q9gba8r1cFdsp/0uAYO3aVn7gnwqCPG W9XmAW8C6XJdG7gHmHRoTlT4sc4Lj9BwliwVb9fN0sSqbF4UlABupXlIZTyuCBS1
Public only: t6yVboVvHOyCpOH7/hdA2cRlmkDoMZJc3cC72PpakR2/7dbq9Lqc1a+MY09sOMDH AQAB