Menu

Hard time creating RSA key pair

Help
timucin
2014-03-10
2014-03-10
  • timucin

    timucin - 2014-03-10

    I am planning on creating RSA key pairs on client side so that i won't have to transfer any private key but when i use RSA. generate function, i get the necessary values for the keys but cannot wrap them to use in pidCrypt later on. How do you do it?

     
  • Jonah (pidder)

    Jonah (pidder) - 2014-03-10

    For the public key use

    pidCrypt.RSA.setPublic(N,E,radix)
    

    where N is the modulus and E is the public exponent, respectively.
    In case those values are not in hexadecimal representation, also enter a radix (defaults to 16).

    For the private key use

    pidCrypt.RSA.setPrivateEx(N,E,D,P,Q,DP,DQ,C,radix)
    

    with

    N: modulus
    E: public exponent
    D: private exponent
    P: Prime1
    Q: Prime2
    DP: exponent1
    DQ: exponent2
    C: coefficient

    (see http://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf for details of these parameters). Again, if these values are not in hex, enter the radix of their representation.

    If you used pidCrypt.RSA.generate to generate the keys, those parameters are already stored as properties of pidcrypt.RSA, e.g. pidcrypt.RSA.n, pidcrypt.RSA.e, etc.

    However, we do not recommend creating RSA keys with client side javascript, since there are concerns about the randomness of the JS random number generation.

     

    Last edit: Jonah (pidder) 2014-03-10

Log in to post a comment.

MongoDB Logo MongoDB