Esempio n. 1
0
 public void putRawPublicKey(PublicKey key) {
   if (key instanceof RSAPublicKey) {
     putString(KeyPairProvider.SSH_RSA);
     putMPInt(((RSAPublicKey) key).getPublicExponent());
     putMPInt(((RSAPublicKey) key).getModulus());
   } else if (key instanceof DSAPublicKey) {
     putString(KeyPairProvider.SSH_DSS);
     putMPInt(((DSAPublicKey) key).getParams().getP());
     putMPInt(((DSAPublicKey) key).getParams().getQ());
     putMPInt(((DSAPublicKey) key).getParams().getG());
     putMPInt(((DSAPublicKey) key).getY());
   } else {
     throw new IllegalStateException("Unsupported algorithm: " + key.getAlgorithm());
   }
 }
Esempio n. 2
0
 public void putKeyPair(KeyPair key) {
   if (key.getPrivate() instanceof RSAPrivateCrtKey) {
     putString(KeyPairProvider.SSH_RSA);
     putMPInt(((RSAPublicKey) key.getPublic()).getPublicExponent());
     putMPInt(((RSAPublicKey) key.getPublic()).getModulus());
     putMPInt(((RSAPrivateCrtKey) key.getPrivate()).getPrivateExponent());
     putMPInt(((RSAPrivateCrtKey) key.getPrivate()).getCrtCoefficient());
     putMPInt(((RSAPrivateCrtKey) key.getPrivate()).getPrimeQ());
     putMPInt(((RSAPrivateCrtKey) key.getPrivate()).getPrimeP());
   } else if (key.getPublic() instanceof DSAPublicKey) {
     putString(KeyPairProvider.SSH_DSS);
     putMPInt(((DSAPublicKey) key.getPublic()).getParams().getP());
     putMPInt(((DSAPublicKey) key.getPublic()).getParams().getQ());
     putMPInt(((DSAPublicKey) key.getPublic()).getParams().getG());
     putMPInt(((DSAPublicKey) key.getPublic()).getY());
     putMPInt(((DSAPrivateKey) key.getPrivate()).getX());
   } else {
     throw new IllegalStateException("Unsupported algorithm: " + key.getPublic().getAlgorithm());
   }
 }
Esempio n. 3
0
 public void putMPInt(BigInteger bi) {
   putMPInt(bi.toByteArray());
 }