public static byte[] getEncodedPrivateKeyInfo(PrivateKeyInfo info) { try { return info.getEncoded(ASN1Encoding.DER); } catch (Exception e) { return null; } } }
public static byte[] getEncodedPrivateKeyInfo(PrivateKeyInfo info) { try { return info.getEncoded(ASN1Encoding.DER); } catch (Exception e) { return null; } } }
public static byte[] getEncodedPrivateKeyInfo(PrivateKeyInfo info) { try { return info.getEncoded(ASN1Encoding.DER); } catch (Exception e) { return null; } } }
public PrivateKey getPrivateKey(PrivateKeyInfo privateKeyInfo) throws PEMException { try { KeyFactory keyFactory = getKeyFactory(privateKeyInfo.getPrivateKeyAlgorithm()); return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKeyInfo.getEncoded())); } catch (Exception e) { throw new PEMException("unable to convert key pair: " + e.getMessage(), e); } }
public PrivateKey getPrivateKey(PrivateKeyInfo privateKeyInfo) throws PEMException { try { KeyFactory keyFactory = getKeyFactory(privateKeyInfo.getPrivateKeyAlgorithm()); return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKeyInfo.getEncoded())); } catch (Exception e) { throw new PEMException("unable to convert key pair: " + e.getMessage(), e); } }
public KeyPair getKeyPair(PEMKeyPair keyPair) throws PEMException { try { KeyFactory keyFactory = getKeyFactory(keyPair.getPrivateKeyInfo().getPrivateKeyAlgorithm()); return new KeyPair(keyFactory.generatePublic(new X509EncodedKeySpec(keyPair.getPublicKeyInfo().getEncoded())), keyFactory.generatePrivate(new PKCS8EncodedKeySpec(keyPair.getPrivateKeyInfo().getEncoded()))); } catch (Exception e) { throw new PEMException("unable to convert key pair: " + e.getMessage(), e); } }
public KeyPair getKeyPair(PEMKeyPair keyPair) throws PEMException { try { KeyFactory keyFactory = getKeyFactory(keyPair.getPrivateKeyInfo().getPrivateKeyAlgorithm()); return new KeyPair(keyFactory.generatePublic(new X509EncodedKeySpec(keyPair.getPublicKeyInfo().getEncoded())), keyFactory.generatePrivate(new PKCS8EncodedKeySpec(keyPair.getPrivateKeyInfo().getEncoded()))); } catch (Exception e) { throw new PEMException("unable to convert key pair: " + e.getMessage(), e); } }
public PKCS8EncryptedPrivateKeyInfo build( OutputEncryptor encryptor) { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); OutputStream cOut = encryptor.getOutputStream(bOut); cOut.write(privateKeyInfo.getEncoded()); cOut.close(); return new PKCS8EncryptedPrivateKeyInfo(new EncryptedPrivateKeyInfo(encryptor.getAlgorithmIdentifier(), bOut.toByteArray())); } catch (IOException e) { throw new IllegalStateException("cannot encode privateKeyInfo"); } } }
public PKCS8EncryptedPrivateKeyInfo build( OutputEncryptor encryptor) { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); OutputStream cOut = encryptor.getOutputStream(bOut); cOut.write(privateKeyInfo.getEncoded()); cOut.close(); return new PKCS8EncryptedPrivateKeyInfo(new EncryptedPrivateKeyInfo(encryptor.getAlgorithmIdentifier(), bOut.toByteArray())); } catch (IOException e) { throw new IllegalStateException("cannot encode privateKeyInfo"); } } }
public byte[] getEncoded() { RainbowPrivateKey privateKey = new RainbowPrivateKey(A1inv, b1, A2inv, b2, vi, layers); PrivateKeyInfo pki; try { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.rainbow, DERNull.INSTANCE); pki = new PrivateKeyInfo(algorithmIdentifier, privateKey); } catch (IOException e) { return null; } try { byte[] encoded = pki.getEncoded(); return encoded; } catch (IOException e) { return null; } }
public byte[] getEncoded() { PrivateKeyInfo pki; try { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.newHope); short[] privateKeyData = params.getSecData(); byte[] octets = new byte[privateKeyData.length * 2]; for (int i = 0; i != privateKeyData.length; i++) { Pack.shortToLittleEndian(privateKeyData[i], octets, i * 2); } pki = new PrivateKeyInfo(algorithmIdentifier, new DEROctetString(octets)); return pki.getEncoded(); } catch (IOException e) { return null; } }
/** * Return a PKCS8 representation of the key. The sequence returned * represents a full PrivateKeyInfo object. * * @return a PKCS8 representation of the key. */ public byte[] getEncoded() { try { if (info != null) { return info.getEncoded(ASN1Encoding.DER); } PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.dhKeyAgreement, new DHParameter(dhSpec.getP(), dhSpec.getG(), dhSpec.getL())), new ASN1Integer(getX())); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
/** * Return a PKCS8 representation of the key. The sequence returned * represents a full PrivateKeyInfo object. * * @return a PKCS8 representation of the key. */ public byte[] getEncoded() { try { if (info != null) { return info.getEncoded(ASN1Encoding.DER); } PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.dhKeyAgreement, new DHParameter(dhSpec.getP(), dhSpec.getG(), dhSpec.getL()).toASN1Primitive()), new ASN1Integer(getX())); return info.getEncoded(ASN1Encoding.DER); } catch (Exception e) { return null; } }
public byte[] getEncoded() { PrivateKeyInfo pki; try { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss, new XMSSKeyParams(keyParams.getParameters().getHeight(), new AlgorithmIdentifier(treeDigest))); pki = new PrivateKeyInfo(algorithmIdentifier, createKeyStructure()); return pki.getEncoded(); } catch (IOException e) { return null; } }
public byte[] getEncoded() { PrivateKeyInfo pki; try { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.sphincs256, new SPHINCS256KeyParams(new AlgorithmIdentifier(treeDigest))); pki = new PrivateKeyInfo(algorithmIdentifier, new DEROctetString(params.getKeyData())); return pki.getEncoded(); } catch (IOException e) { return null; } }
/** * Return a PKCS8 representation of the key. The sequence returned * represents a full PrivateKeyInfo object. * * @return a PKCS8 representation of the key. */ public byte[] getEncoded() { try { PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG())), new DERInteger(getX())); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
public byte[] getEncoded() { PrivateKeyInfo pki; try { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss_mt, new XMSSMTKeyParams(keyParams.getParameters().getHeight(), keyParams.getParameters().getLayers(), new AlgorithmIdentifier(treeDigest))); pki = new PrivateKeyInfo(algorithmIdentifier, createKeyStructure()); return pki.getEncoded(); } catch (IOException e) { return null; } }
/** * Return a PKCS8 representation of the key. The sequence returned * represents a full PrivateKeyInfo object. * * @return a PKCS8 representation of the key. */ public byte[] getEncoded() { try { PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG())), new ASN1Integer(getX())); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
/** * Return a PKCS8 representation of the key. The sequence returned * represents a full PrivateKeyInfo object. * * @return a PKCS8 representation of the key. */ public byte[] getEncoded() { try { PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new ASN1Integer(getX())); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
/** * Return a PKCS8 representation of the key. The sequence returned * represents a full PrivateKeyInfo object. * * @return a PKCS8 representation of the key. */ public byte[] getEncoded() { try { PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(getX())); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }