public static PrivateKeyInfo getInstance( Object obj) { if (obj instanceof PrivateKeyInfo) { return (PrivateKeyInfo)obj; } else if (obj != null) { return new PrivateKeyInfo(ASN1Sequence.getInstance(obj)); } return null; }
public static PrivateKeyInfo getInstance( Object obj) { if (obj instanceof PrivateKeyInfo) { return (PrivateKeyInfo)obj; } else if (obj != null) { return new PrivateKeyInfo(ASN1Sequence.getInstance(obj)); } return null; }
public static byte[] getEncodedPrivateKeyInfo(AlgorithmIdentifier algId, ASN1Encodable privKey) { try { PrivateKeyInfo info = new PrivateKeyInfo(algId, privKey.toASN1Primitive()); return getEncodedPrivateKeyInfo(info); } catch (Exception e) { return null; } }
public static byte[] getEncodedPrivateKeyInfo(AlgorithmIdentifier algId, ASN1Encodable privKey) { try { PrivateKeyInfo info = new PrivateKeyInfo(algId, privKey.toASN1Primitive()); return getEncodedPrivateKeyInfo(info); } catch (Exception e) { return null; } }
public static byte[] getEncodedPrivateKeyInfo(AlgorithmIdentifier algId, ASN1Encodable privKey) { try { PrivateKeyInfo info = new PrivateKeyInfo(algId, privKey.toASN1Primitive()); return getEncodedPrivateKeyInfo(info); } catch (Exception e) { return null; } }
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; } }
public PEMKeyPair parse(byte[] encoding) throws IOException { try { ASN1Sequence seq = ASN1Sequence.getInstance(encoding); org.spongycastle.asn1.sec.ECPrivateKey pKey = org.spongycastle.asn1.sec.ECPrivateKey.getInstance(seq); AlgorithmIdentifier algId = new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, pKey.getParameters()); PrivateKeyInfo privInfo = new PrivateKeyInfo(algId, pKey); SubjectPublicKeyInfo pubInfo = new SubjectPublicKeyInfo(algId, pKey.getPublicKey().getBytes()); return new PEMKeyPair(pubInfo, privInfo); } catch (IOException e) { throw e; } catch (Exception e) { throw new PEMException( "problem creating EC private key: " + e.toString(), e); } } }
public PEMKeyPair parse(byte[] encoding) throws IOException { try { ASN1Sequence seq = ASN1Sequence.getInstance(encoding); org.spongycastle.asn1.sec.ECPrivateKey pKey = org.spongycastle.asn1.sec.ECPrivateKey.getInstance(seq); AlgorithmIdentifier algId = new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, pKey.getParameters()); PrivateKeyInfo privInfo = new PrivateKeyInfo(algId, pKey); SubjectPublicKeyInfo pubInfo = new SubjectPublicKeyInfo(algId, pKey.getPublicKey().getBytes()); return new PEMKeyPair(pubInfo, privInfo); } catch (IOException e) { throw e; } catch (Exception e) { throw new PEMException( "problem creating EC private key: " + e.toString(), e); } } }
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; } }
/** * 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())), new DERInteger(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; } }
/** * 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; } }