public static byte[] getEncodedSubjectPublicKeyInfo(SubjectPublicKeyInfo info) { try { return info.getEncoded(ASN1Encoding.DER); } catch (Exception e) { return null; } }
public static byte[] getEncodedSubjectPublicKeyInfo(SubjectPublicKeyInfo info) { try { return info.getEncoded(ASN1Encoding.DER); } catch (Exception e) { return null; } }
public static byte[] getEncodedSubjectPublicKeyInfo(SubjectPublicKeyInfo info) { try { return info.getEncoded(ASN1Encoding.DER); } catch (Exception e) { return null; } }
public PublicKey getPublicKey(SubjectPublicKeyInfo publicKeyInfo) throws PEMException { try { KeyFactory keyFactory = getKeyFactory(publicKeyInfo.getAlgorithm()); return keyFactory.generatePublic(new X509EncodedKeySpec(publicKeyInfo.getEncoded())); } catch (Exception e) { throw new PEMException("unable to convert key pair: " + e.getMessage(), e); } }
public PublicKey getPublicKey(SubjectPublicKeyInfo publicKeyInfo) throws PEMException { try { KeyFactory keyFactory = getKeyFactory(publicKeyInfo.getAlgorithm()); return keyFactory.generatePublic(new X509EncodedKeySpec(publicKeyInfo.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); } }
PublicKey toPublicKey(SubjectPublicKeyInfo subjectPublicKeyInfo) throws CRMFException { try { X509EncodedKeySpec xspec = new X509EncodedKeySpec(subjectPublicKeyInfo.getEncoded()); AlgorithmIdentifier keyAlg = subjectPublicKeyInfo.getAlgorithm(); return createKeyFactory(keyAlg.getAlgorithm()).generatePublic(xspec); } catch (Exception e) { throw new CRMFException("invalid key: " + 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); } }
PublicKey toPublicKey(SubjectPublicKeyInfo subjectPublicKeyInfo) throws CRMFException { try { X509EncodedKeySpec xspec = new X509EncodedKeySpec(subjectPublicKeyInfo.getEncoded()); AlgorithmIdentifier keyAlg = subjectPublicKeyInfo.getAlgorithm(); return createKeyFactory(keyAlg.getAlgorithm()).generatePublic(xspec); } catch (Exception e) { throw new CRMFException("invalid key: " + e.getMessage(), e); } }
public byte[] getEncoded() { SubjectPublicKeyInfo pki; try { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.newHope); pki = new SubjectPublicKeyInfo(algorithmIdentifier, params.getPubData()); return pki.getEncoded(); } catch (IOException e) { return null; } }
public PKMACValue generate(char[] password, SubjectPublicKeyInfo keyInfo) throws CRMFException { MacCalculator calculator = builder.build(password); OutputStream macOut = calculator.getOutputStream(); try { macOut.write(keyInfo.getEncoded(ASN1Encoding.DER)); macOut.close(); } catch (IOException e) { throw new CRMFException("exception encoding mac input: " + e.getMessage(), e); } return new PKMACValue(calculator.getAlgorithmIdentifier(), new DERBitString(calculator.getMac())); } }
static byte[] calculateKeyId(SubjectPublicKeyInfo info) { SHA1Digest dig = new SHA1Digest(); byte[] hash = new byte[dig.getDigestSize()]; byte[] spkiEnc = new byte[0]; try { spkiEnc = info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return new byte[0]; } // try the outlook 2010 calculation dig.update(spkiEnc, 0, spkiEnc.length); dig.doFinal(hash, 0); return hash; }
public boolean isValid(PKMACValue value, char[] password, SubjectPublicKeyInfo keyInfo) throws CRMFException { builder.setParameters(PBMParameter.getInstance(value.getAlgId().getParameters())); MacCalculator calculator = builder.build(password); OutputStream macOut = calculator.getOutputStream(); try { macOut.write(keyInfo.getEncoded(ASN1Encoding.DER)); macOut.close(); } catch (IOException e) { throw new CRMFException("exception encoding mac input: " + e.getMessage(), e); } return Arrays.areEqual(calculator.getMac(), value.getValue().getBytes()); } }
public byte[] getEncoded() { SubjectPublicKeyInfo pki; try { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.sphincs256, new SPHINCS256KeyParams(new AlgorithmIdentifier(treeDigest))); pki = new SubjectPublicKeyInfo(algorithmIdentifier, params.getKeyData()); return pki.getEncoded(); } catch (IOException e) { return null; } }
public byte[] getEncoded() { try { if (dsaSpec == null) { return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y)).getEncoded(ASN1Encoding.DER); } return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new ASN1Integer(y)).getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
public byte[] getEncoded() { try { if (dsaSpec == null) { return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new DERInteger(y)).getEncoded(ASN1Encoding.DER); } return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(y)).getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
public byte[] getEncoded() { try { SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG())), new DERInteger(y)); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
public byte[] getEncoded() { try { SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG())), new ASN1Integer(y)); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
public byte[] getEncoded() { SubjectPublicKeyInfo pki; try { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss, new XMSSKeyParams(keyParams.getParameters().getHeight(), new AlgorithmIdentifier(treeDigest))); pki = new SubjectPublicKeyInfo(algorithmIdentifier, new XMSSPublicKey(keyParams.getPublicSeed(), keyParams.getRoot())); return pki.getEncoded(); } catch (IOException e) { return null; } }
public byte[] getEncoded() { SubjectPublicKeyInfo pki; try { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss_mt, new XMSSMTKeyParams(keyParams.getParameters().getHeight(), keyParams.getParameters().getLayers(), new AlgorithmIdentifier(treeDigest))); pki = new SubjectPublicKeyInfo(algorithmIdentifier, new XMSSPublicKey(keyParams.getPublicSeed(), keyParams.getRoot())); return pki.getEncoded(); } catch (IOException e) { return null; } }