Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I used rsa-json.native to generate RSA keys for a node.js application that will use secure-peer later to connect two clients with each other. Now I have 2 questions:

  • In secure-peer/index.js I've found defaultCiphers = ['RC4'] - is this acceptable? I've heard that RC4 is broken.
  • Are my example RSA keys flawed? They contain the same data at the end and beginning of the keys.

RSA-Key #1:

-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBALJWTxyvIedsbg4QffU7vqvBlsHR8w6dfN19bSMiVjdSPoU2mKGN+n/Ck5gTPrWK
zz64JRrLWE7pYsd1YF1RQIbh8eUUNA3cUmVpuAdfolwpE3ixFlaYRgwGjwkaONoGerP9p1SS
VUCwuEfgmS14n5x9AQ/3HJVICQTb/2dryQqFAgMBAAE=
-----END RSA PUBLIC KEY-----

-----BEGIN RSA PRIVATE KEY-----
MIICWwIBAAKBgQCyVk8cryHnbG4OEH31O76rwZbB0fMOnXzdfW0jIlY3Uj6FNpihjfp/wpOY
Ez61is8+uCUay1hO6WLHdWBdUUCG4fHlFDQN3FJlabgHX6JcKRN4sRZWmEYMBo8JGjjaBnqz
/adUklVAsLhH4JkteJ+cfQEP9xyVSAkE2/9na8kKhQIDAQABAoGAJpEtyLlDLsYvQtFkPA2w
nXpfPQlHdCiw4UGHwapiVNJvfOWiuoV23/xXaPL4g9BCI4E1XQcO0Pn+B76lmWjB+EvVLTnw
SM0M/coY73mOT/Suc51OKG+cd9HnYjNe9hzwkbIwX73AcgyWRGYt0NAPbAFBM/xxLPNzSeyo
othjFYECQQD9BD/HDwbNycu3mhPOlhPU605xcZnWb2IOcSWoNb6zlq4JcVXXR/Nb1R4qPSBU
s+thdtc6Lpk+0Fr/iQaJ9f3hAkEAtHCiTQbsDBlR8ypCfau2CmHZ8nLMlYhtarzfcJ5PJZ0d
zQOVdcdivC5gIGs0t6+UH4KKbFBPSvuNH+pwZbx5JQJAAaj7eiThGIyQZ539L0fQzX7VvuzN
45hLf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QQC3AH5Qa8MAbBZtKHIRursMSfq8
UaM+hkTuVHCrG3dle8LlyEcvG+4cWFkuly4Tv7dZMAMEYg3JqAXORUXy5YtdAkARFTMeFvKo
1Yp/AYWGwPcKW1pxNoM8zlbzWPunGY8V1KPh8VY5ECtt3Lp6lx1vB5FcIBD9PjMKKVA8y935
xB7fAkEAsbtvwg3leiFz8biyWib8Gq7KDSEZOeBFKbPu7zDHR7koCxJoqjUtBA6WSJ6td5b+
RjnPQl6sh+lyQ1gEuAJMJA==
-----END RSA PRIVATE KEY-----
share|improve this question
1  
Just to emphasize: Don't use these specific keys for anything now. If the private key was published, anyone could try it and break your cipher/signature. –  Paŭlo Ebermann Jun 9 at 14:15
    
I know, I just used these to make my point clear. I will not use them for anything important. –  Florian W. Jun 9 at 18:54

1 Answer 1

up vote 2 down vote accepted

defaultCiphers = ['RC4'] - is this acceptable? I've heard that RC4 is broken.

About RC4 vulnerabilities in general, see e.g. Google is using RC4, but isn't RC4 considered unsafe?

RC4 can be secure when you discard (enough of) the beginning of the keystream or use a new key each session. Since node.js calls into OpenSSL, I don't think it does the former and can't see it done in secure-peer either.

From a look at the secure-peer source, it seems like they use Diffie-Hellman to get a shared secret and use that to derive the RC4 key and IV. That is should be safe, but I could be reading it wrong.

To test, you could try printing secret before this line:

var encrypt = crypto.createCipher(cipher, secret);

If it's different each time (for the same pair of peers), it's probably fine. Otherwise, there may be cause for concern.

Are my example RSA keys flawed?

They certainly are now that you published them :)

But, no, probably not. RSA keys are stored in one of several formats that have some leading and trailing data that is similar for keys made using the same implementation.

  1. The keys have format and version tags.
  2. They may have information regarding whether the key is stored encrypted and with what algorithm, presumably the same.
  3. The public key exponent is usually chosen as e.g. 65537 for all keys.
share|improve this answer
2  
Small addition re format: rfc4880 is for OpenPGP. The asker's data are OpenSSL formats which are based on PKCS#1 which is rfc3447, and X.509 which is mostly rfc5280 and which builds on PKCS#1. Both are PEM-ized ASN.1 DER, which includes encoding prefixes, a version value for private, and an AlgorithmIdentifier value for public; these result in the first several octets of all keys being mostly the same. The case asked isn't encrypted, but OpenSSL PKCS#1 private key when encrypted is specified in a PEM header, not within in the data. ... –  dave_thompson_085 Jun 9 at 9:40
1  
... OpenSSL (especially since 1.0.0) also supports another private-key format PKCS#8 rfc5208 which is ASN.1 with prefixes, version AND AlgorithmIdentifier, and when encrypted DOES have the encryption information in the data -- although the encryption information will be at most partly constant. –  dave_thompson_085 Jun 9 at 9:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.