private static byte[] getEncodedSubKeyId(byte[] subjectKeyIdentifier) { try { return new DEROctetString(subjectKeyIdentifier).getEncoded(); } catch (final IOException e) { throw new IllegalArgumentException("Cannot process subject key identifier: " + e.getMessage()) { public Throwable getCause() { return e; } }; } }
private static byte[] getEncodedSubKeyId(byte[] subjectKeyIdentifier) { try { return new DEROctetString(subjectKeyIdentifier).getEncoded(); } catch (final IOException e) { throw new IllegalArgumentException("Cannot process subject key identifier: " + e.getMessage()) { public Throwable getCause() { return e; } }; } }
protected byte[] engineSign() throws SignatureException { byte[] hash = new byte[digest.getDigestSize()]; digest.doFinal(hash, 0); try { BigInteger[] sig = signer.generateSignature(hash); byte[] r = sig[0].toByteArray(); byte[] s = sig[1].toByteArray(); byte[] sigBytes = new byte[(r.length > s.length ? r.length * 2 : s.length * 2)]; System.arraycopy(s, 0, sigBytes, (sigBytes.length / 2) - s.length, s.length); System.arraycopy(r, 0, sigBytes, sigBytes.length - r.length, r.length); return new DEROctetString(sigBytes).getEncoded(); } catch (Exception e) { throw new SignatureException(e.toString()); } }
protected byte[] engineGetEncoded( String format) throws IOException { if (isASN1FormatString(format)) { return new DEROctetString(engineGetEncoded("RAW")).getEncoded(); } if (format.equals("RAW")) { return Arrays.clone(iv); } return null; }
protected byte[] engineGetEncoded( String format) throws IOException { if (isASN1FormatString(format)) { return new DEROctetString(engineGetEncoded("RAW")).getEncoded(); } if (format.equals("RAW")) { return Arrays.clone(iv); } return null; }
selector.setSubjectKeyIdentifier(new DEROctetString(subjectKeyIdentifier).getEncoded());
protected byte[] engineSign() throws SignatureException { byte[] signature = ASN1OctetString.getInstance(super.engineSign()).getOctets(); reverseBytes(signature); try { return (new DEROctetString(signature)).getEncoded(); } catch (Exception e) { throw new SignatureException(e.toString()); } }
selector.setSubjectKeyIdentifier(new DEROctetString(subjectKeyIdentifier).getEncoded());
protected static byte[] getPartyVInfoFromRID(KeyTransRecipientId recipientId) throws IOException { if (recipientId.getSerialNumber() != null) { return new IssuerAndSerialNumber(recipientId.getIssuer(), recipientId.getSerialNumber()).getEncoded(ASN1Encoding.DER); } else { return new DEROctetString(recipientId.getSubjectKeyIdentifier()).getEncoded(); } } }
protected static byte[] getPartyVInfoFromRID(KeyTransRecipientId recipientId) throws IOException { if (recipientId.getSerialNumber() != null) { return new IssuerAndSerialNumber(recipientId.getIssuer(), recipientId.getSerialNumber()).getEncoded(ASN1Encoding.DER); } else { return new DEROctetString(recipientId.getSubjectKeyIdentifier()).getEncoded(); } } }
return super.engineVerify((new DEROctetString(bytes)).getEncoded());
if (authorityKeyIdentifier != null) selector.setSubjectKeyIdentifier(new DEROctetString(authorityKeyIdentifier).getEncoded());
if (keyID != null) certSelectX509.setSubjectKeyIdentifier(new DEROctetString(keyID).getEncoded());
if (keyID != null) certSelectX509.setSubjectKeyIdentifier(new DEROctetString(keyID).getEncoded());
/** * Generates an OCSP request using BouncyCastle. * * @param issuerCert certificate of the issues * @param serialNumber serial number * @return an OCSP request * @throws OCSPException * @throws IOException */ private static OCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws OCSPException, IOException, OperatorException, CertificateEncodingException { //Add provider BC Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider()); // Generate the id for the certificate we are looking for CertificateID id = new CertificateID( new JcaDigestCalculatorProviderBuilder().build().get(CertificateID.HASH_SHA1), new JcaX509CertificateHolder(issuerCert), serialNumber); // basic request generation with nonce OCSPReqBuilder gen = new OCSPReqBuilder(); gen.addRequest(id); Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(new DEROctetString(PdfEncryption.createDocumentId()).getEncoded())); gen.setRequestExtensions(new Extensions(new Extension[]{ext})); return gen.build(); }