private static GeneralName ipGeneralName(InetAddress hostAddress) { return new GeneralName(GeneralName.iPAddress, new DEROctetString(hostAddress.getAddress())); }
public CertificateBuilder sanIpAddress(InetAddress hostAddress) throws IOException { subjectAltName = new GeneralNames(new GeneralName(GeneralName.iPAddress, new DEROctetString(hostAddress.getAddress()))).getEncoded(); return this; }
/** * Returns subject alternative names for "localhost". * @return the subject alternative names for "localhost". */ private static GeneralNames getLocalhostSubjectAltNames() throws UnknownHostException { InetAddress[] localAddresses = InetAddress.getAllByName("localhost"); GeneralName[] generalNames = new GeneralName[localAddresses.length + 1]; for (int i = 0; i < localAddresses.length; i++) { generalNames[i] = new GeneralName(GeneralName.iPAddress, new DEROctetString(localAddresses[i].getAddress())); } generalNames[generalNames.length - 1] = new GeneralName(GeneralName.dNSName, new DERIA5String("localhost")); return new GeneralNames(generalNames); }
Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, true, new DEROctetString(nonce.toByteArray())); requestGenerator.setRequestExtensions(new Extensions(new Extension[]{ext}));
byte[] nonce = new byte[16]; rand.nextBytes(nonce); encodedNonce = new DEROctetString(new DEROctetString(nonce)); Extension nonceExtension = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, encodedNonce);
new EncryptedContentInfo(PKCSObjectIdentifiers.data, algorithmId, new DEROctetString(bytes)); EnvelopedData enveloped = new EnvelopedData(null, set, encryptedInfo, (ASN1Set) null);
DERSequenceGenerator seq = new DERSequenceGenerator(s); seq.addObject(new ASN1Integer(blockNumber)); seq.addObject(new DEROctetString(previousHash)); seq.addObject(new DEROctetString(dataHash)); seq.close(); return cryptoSuite.hash(s.toByteArray());
private KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0) throws IOException, CertificateEncodingException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException { TBSCertificate certificate; try (ASN1InputStream input = new ASN1InputStream(x509certificate.getTBSCertificate())) { certificate = TBSCertificate.getInstance(input.readObject()); } AlgorithmIdentifier algorithmId = certificate.getSubjectPublicKeyInfo().getAlgorithm(); IssuerAndSerialNumber serial = new IssuerAndSerialNumber( certificate.getIssuer(), certificate.getSerialNumber().getValue()); Cipher cipher; try { cipher = Cipher.getInstance(algorithmId.getAlgorithm().getId(), SecurityProvider.getProvider()); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { // should never happen, if this happens throw IOException instead throw new RuntimeException("Could not find a suitable javax.crypto provider", e); } cipher.init(1, x509certificate.getPublicKey()); DEROctetString octets = new DEROctetString(cipher.doFinal(abyte0)); RecipientIdentifier recipientId = new RecipientIdentifier(serial); return new KeyTransRecipientInfo(recipientId, algorithmId, octets); }
public ESSCertID( byte[] hash) { certHash = new DEROctetString(hash); }
public ASN1Primitive toASN1Primitive() { return new DEROctetString(getKeyIdentifier()); } }
/** * Return an in-memory, encodable, representation of the OCTET STRING. * * @return a DEROctetString. * @throws IOException if there is an issue loading the data. */ public ASN1Primitive getLoadedObject() throws IOException { return new DEROctetString(stream.toByteArray()); }
public X9ECPoint( ECCurve c, byte[] encoding) { this.c = c; this.encoding = new DEROctetString(Arrays.clone(encoding)); }
static OCSPReq generateOcspRequestWithNonce(CertificateID id) throws IOException, OCSPException { OCSPReqBuilder gen = new OCSPReqBuilder(); gen.addRequest(id); Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(new DEROctetString(PdfEncryption.generateNewDocumentId()).getEncoded())); gen.setRequestExtensions(new Extensions(new Extension[]{ext})); return gen.build(); }
static OCSPReq generateOcspRequestWithNonce(CertificateID id) throws IOException, OCSPException { OCSPReqBuilder gen = new OCSPReqBuilder(); gen.addRequest(id); Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(new DEROctetString(PdfEncryption.generateNewDocumentId()).getEncoded())); gen.setRequestExtensions(new Extensions(new Extension[]{ext})); return gen.build(); }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = DER.vector( new DEROctetString(signerKeyID()), new ASN1Integer(type), new DEROctetString(data())); return new DERSequence(vector); }
public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new DEROctetString(nonce)); if (icvLen != 12) { v.add(new ASN1Integer(icvLen)); } return new DERSequence(v); } }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new SlotIdentifier(slotId)); vector.add(new ASN1Integer(keyType)); vector.add(new DEROctetString(keyValue)); return new DERSequence(vector); }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vec = new ASN1EncodableVector(); vec.add(new DEROctetString(value.getId())); vec.add(new DERUTF8String(value.getLabel())); return new DERSequence(vec); }
public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); // encode <n> v.add(new ASN1Integer(n)); // encode <t> v.add(new ASN1Integer(t)); // encode <matrixG> v.add(new DEROctetString(g.getEncoded())); v.add(digest); return new DERSequence(v); }
private static byte[] buildOCSPResponse(byte[] BasicOCSPResponse) throws IOException { DEROctetString doctet = new DEROctetString(BasicOCSPResponse); ASN1EncodableVector v2 = new ASN1EncodableVector(); v2.add(OCSPObjectIdentifiers.id_pkix_ocsp_basic); v2.add(doctet); ASN1Enumerated den = new ASN1Enumerated(0); ASN1EncodableVector v3 = new ASN1EncodableVector(); v3.add(den); v3.add(new DERTaggedObject(true, 0, new DERSequence(v2))); DERSequence seq = new DERSequence(v3); return seq.getEncoded(); }