org.bouncycastle.asn1.ASN1Primitive Java Examples
The following examples show how to use
org.bouncycastle.asn1.ASN1Primitive.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SM2Algorithm.java From web3sdk with Apache License 2.0 | 6 votes |
public static boolean verify(byte[] data, byte[] signData, String hexPbkX, String hexPbkY) throws IOException { BigInteger biX = new BigInteger(hexPbkX, 16); BigInteger biY = new BigInteger(hexPbkY, 16); ASN1Sequence as = (ASN1Sequence) ASN1Primitive.fromByteArray(signData); BigInteger[] rs = new BigInteger[] { ((ASN1Integer) as.getObjectAt(0)).getValue(), ((ASN1Integer) as.getObjectAt(1)).getValue() }; byte[] r = getEncoded(rs[0]); byte[] s = getEncoded(rs[1]); byte[] rsBytes = new byte[r.length + s.length]; System.arraycopy(r, 0, rsBytes, 0, r.length); System.arraycopy(s, 0, rsBytes, r.length, s.length); return verify(data, rsBytes, biX, biY); }
Example #2
Source File: JarSigner.java From keystore-explorer with GNU General Public License v3.0 | 6 votes |
private static CMSSignedData addTimestamp(String tsaUrl, CMSSignedData signedData) throws IOException { Collection<SignerInformation> signerInfos = signedData.getSignerInfos().getSigners(); // get signature of first signer (should be the only one) SignerInformation si = signerInfos.iterator().next(); byte[] signature = si.getSignature(); // send request to TSA byte[] token = TimeStampingClient.getTimeStampToken(tsaUrl, signature, DigestType.SHA1); // create new SignerInformation with TS attribute Attribute tokenAttr = new Attribute(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken, new DERSet(ASN1Primitive.fromByteArray(token))); ASN1EncodableVector timestampVector = new ASN1EncodableVector(); timestampVector.add(tokenAttr); AttributeTable at = new AttributeTable(timestampVector); si = SignerInformation.replaceUnsignedAttributes(si, at); signerInfos.clear(); signerInfos.add(si); SignerInformationStore newSignerStore = new SignerInformationStore(signerInfos); // create new signed data CMSSignedData newSignedData = CMSSignedData.replaceSigners(signedData, newSignerStore); return newSignedData; }
Example #3
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 6 votes |
public static SlotIdAndObjectId getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof SlotIdAndObjectId) { return (SlotIdAndObjectId) obj; } try { if (obj instanceof ASN1Sequence) { return new SlotIdAndObjectId((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse encoded object: " + ex.getMessage(), ex); } }
Example #4
Source File: PolicyInfo.java From signer with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void parse(ASN1Primitive derObject) { ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject); ASN1Primitive firstObject = derSequence.getObjectAt(0).toASN1Primitive(); this.policyName = new DirectoryString(firstObject.toString()); ASN1Primitive secondObject = derSequence.getObjectAt(1).toASN1Primitive(); String fieldOfApplication = secondObject.toString(); this.fieldOfApplication = new DirectoryString(fieldOfApplication); this.signingPeriod = new SigningPeriod(); this.signingPeriod.parse(derSequence.getObjectAt(2).toASN1Primitive()); int indice = 3; ASN1Primitive revocationObject = derSequence.getObjectAt(indice).toASN1Primitive(); if (!(secondObject instanceof DERTaggedObject)) { indice = 4; } if (indice == 3) { this.revocationDate = new Time(); this.revocationDate.parse(revocationObject); } }
Example #5
Source File: LPA.java From signer with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void parse(ASN1Primitive derObject) { ASN1Sequence sequence = ASN1Object.getDERSequence(derObject); ASN1Primitive policyInfos = sequence.getObjectAt(0).toASN1Primitive(); DLSequence policyInfosSequence = (DLSequence) policyInfos; if (policyInfosSequence != null && policyInfosSequence.size() > 0) { this.policyInfos = new ArrayList<>(); for (int i = 0; i < policyInfosSequence.size(); i++) { PolicyInfo policyInfo = new PolicyInfo(); policyInfo.parse(policyInfosSequence.getObjectAt(i).toASN1Primitive()); this.policyInfos.add(policyInfo); } } this.nextUpdate = new Time(); this.nextUpdate.parse(sequence.getObjectAt(1).toASN1Primitive()); }
Example #6
Source File: DSSASN1UtilsTest.java From dss with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void isArchiveTimeStampTokenTest() { String atstV2 = "MIIIhwYLKoZIhvcNAQkQAjAxggh2MIIIcgYJKoZIhvcNAQcCoIIIYzCCCF8CAQMxDzANBglghkgBZQMEAgEFADCCARMGCyqGSIb3DQEJEAEEoIIBAgSB/zCB/AIBAQYKKwYBBAH7SwUCAjAxMA0GCWCGSAFlAwQCAQUABCAm67S7cA/ArzsncKnDKJk7AQVkbbH2LmjhxjNFGKEKeAIVAKQr5q6pobk+BGS1xZJBa0LrWjgtGBMyMDE4MDUwNzE0MTMxNy41OTNaMAOAAQECCQDdRKjMw1Tj/aB8pHoweDEpMCcGA1UEAxMgVW5pdmVyc2lnbiBUaW1lc3RhbXBpbmcgVW5pdCAwMjExHDAaBgNVBAsTEzAwMDIgNDM5MTI5MTY0MDAwMjYxIDAeBgNVBAoTF0NyeXB0b2xvZyBJbnRlcm5hdGlvbmFsMQswCQYDVQQGEwJGUqCCBGAwggRcMIIDRKADAgECAhBaH/CXaf7oPTjm1eRV0Qf/MA0GCSqGSIb3DQEBCwUAMHcxCzAJBgNVBAYTAkZSMSAwHgYDVQQKExdDcnlwdG9sb2cgSW50ZXJuYXRpb25hbDEcMBoGA1UECxMTMDAwMiA0MzkxMjkxNjQwMDAyNjEoMCYGA1UEAxMfVW5pdmVyc2lnbiBUaW1lc3RhbXBpbmcgQ0EgMjAxNTAeFw0xODA0MjYxNjE5MjZaFw0yNDA0MjYxNjE5MjZaMHgxKTAnBgNVBAMTIFVuaXZlcnNpZ24gVGltZXN0YW1waW5nIFVuaXQgMDIxMRwwGgYDVQQLExMwMDAyIDQzOTEyOTE2NDAwMDI2MSAwHgYDVQQKExdDcnlwdG9sb2cgSW50ZXJuYXRpb25hbDELMAkGA1UEBhMCRlIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwgg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VBAoTF0NyeXB0b2xvZyBJbnRlcm5hdGlvbmFsMRwwGgYDVQQLExMwMDAyIDQzOTEyOTE2NDAwMDI2MSgwJgYDVQQDEx9Vbml2ZXJzaWduIFRpbWVzdGFtcGluZyBDQSAyMDE1AhBaH/CXaf7oPTjm1eRV0Qf/MA0GCWCGSAFlAwQCAQUAoIIBETAaBgkqhkiG9w0BCQMxDQYLKoZIhvcNAQkQAQQwLwYJKoZIhvcNAQkEMSIEINTyZn1Qwk+ObcyBn8lOomMd1ONT4hIgFTENpywHUxbEMIHBBgsqhkiG9w0BCRACDDGBsTCBrjCBqzCBqAQUCPAR2aMafE51hsHQENTQcKe6lWAwgY8we6R5MHcxCzAJBgNVBAYTAkZSMSAwHgYDVQQKExdDcnlwdG9sb2cgSW50ZXJuYXRpb25hbDEcMBoGA1UECxMTMDAwMiA0MzkxMjkxNjQwMDAyNjEoMCYGA1UEAxMfVW5pdmVyc2lnbiBUaW1lc3RhbXBpbmcgQ0EgMjAxNQIQWh/wl2n+6D045tXkVdEH/zANBgkqhkiG9w0BAQsFAASCAQA4NsVVHBUrIs+zoonsl2eFUVwBehoTZJJvLSp41Q3jdAci2ppTzL/8rsvlv3RwDc6lMcOFDZhSuKOIT8rLXPg050xAglxUzkN0r9WpscQ6/cfJZmvVTf01gERTYuqrLhs5lF2qdEOty+42VeJB4hW/gAunEQxJuOyO1xGRBkgyIQq2t63FcwR/+Qw9IWRByNp15Bdt30HpvmyvhR3y/T4hK/9NatRAxoBIRhHXlwUT15Bphf22bDuOyEJyOYnviAvpcUq0g5v7KQcIJdmk93elzo+n8yIwCS7lm3XhZYLsyocLbQBP6oNCZlrNZ4YL4SuMcP0JWW7jfj/+OzWGax8H"; ASN1Primitive asn1Primitive = DSSASN1Utils.toASN1Primitive(Utils.fromBase64(atstV2)); Attribute atstV2Attibute = new Attribute(OID.id_aa_ets_archiveTimestampV2, new DERSet(asn1Primitive)); assertTrue(DSSASN1Utils.isArchiveTimeStampToken(atstV2Attibute));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SSASN1Utils.toASN1Primitive(Utils.fromBase64(atstV3)); Attribute atstV3Attibute = new Attribute(OID.id_aa_ets_archiveTimestampV3, new DERSet(asn1Primitive)); assertTrue(DSSASN1Utils.isArchiveTimeStampToken(atstV3Attibute)); String sigTst = "MIIVJQYJKoZIhvcNAQcCoIIVFjCCFRICAQMxDzANBglghkgBZQMEAgEFADCCARMGCyqGSIb3DQEJEAEEoIIBAgSB/zCB/AIBAQYKKwYBBAH7SwUCAjAxMA0GCWCGSAFlAwQCAQUABCBT2S93XuvGV5XB9P74rlXpEBNQw7v+LkhVqlWcwyGgDwIVAKzJneGO+8crMY8T0qaCcD2284U4GBMyMDE4MDUwNzE0MTMxMS4xMDRaMAOAAQECCQDAIEqncxQduqB8pHoweDEpMCcGA1UEAxMgVW5pdmVyc2lnbiBUaW1lc3RhbXBpbmcgVW5pdCAwMjAxHDAaBgNVBAsTEzAwMDIgNDM5MTI5MTY0MDAwMjYxIDAeBgNVBAoTF0NyeXB0b2xvZyBJbnRlcm5hdGlvbmFsMQswCQYDVQQGEwJGUqCCBGEwggRdMIIDRaADAgECAhEArBfUtF0gHC6S0qdGjvl/XDANBgkqhkiG9w0BAQsFADB3MQswCQYDVQQGEwJGUjEgMB4GA1UEChMXQ3J5cHRvbG9nIEludGVybmF0aW9uYWwxHDAaBgNVBAsTEzAwMDIgNDM5MTI5MTY0MDAwMjYxKDAmBgNVBAMTH1VuaXZlcnNpZ24gVGltZXN0YW1waW5nIENBIDIwMTUwHhcNMTgwNDI2MTYxMDIxWhcNMjQwNDI2MTYxMDIxWjB4MSkwJwYDVQQDEyBVbml2ZXJzaWduIFRpbWVzdGFtcGluZyBVbml0IDAyMDEcMBoGA1UECxMTMDAwMiA0MzkxMjkxNjQwMDAyNjEgMB4GA1UEChMXQ3J5cHRvbG9nIEludGVybmF0aW9uYWwxCzAJBgNVBAYTAkZSMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl6X5QfrFNO3B94xi9xV9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uZie0LiaMN0m3dt97rZihteCzXnlhgNf1/Fww+DfolE2gnma+R1L+JUZ/LEwbQHmg0xJNbU4ZDYhvPpsZUhmjBFhQOIM1hmrZsuV847LQNCJws0NDYR+B+It0Qljt1SXlf9qTK5mw4btPLbn5pGmswqOclvlnf97iWDaFSzikRjZYPDPeKG36RLW3SFv3DeLjfUNpIwNZqPEWWCHGY+NNRDUacuR0w+Il0QASgA/tzwERPcvdpoAdj0XOOednUdjdVTAuOruSNZ1vb6Yix0F8CAwEAAaOB4jCB3zAJBgNVHRMEAjAAMEEGA1UdIAQ6MDgwNgYKKwYBBAH7SwUBATAoMCYGCCsGAQUFBwIBFhpodHRwOi8vZG9jcy51bml2ZXJzaWduLmV1LzBGBgNVHR8EPzA9MDugOaA3hjVodHRwOi8vY3JsLnVuaXZlcnNpZ24uZXUvdW5pdmVyc2lnbl90c2Ffcm9vdF8yMDE1LmNybDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAwwCgYIKwYBBQUHAwgwHwYDVR0jBBgwFoAU+k3tVzu9P/ORM5oLOaR/XRLdB0YwDQYJKoZIhvcNAQELBQADggEBADNaZmy7AZ0OsCKPnmQOxpvbIFTxZFerE/4ysyPlVd9f15bgreBWekK0MaTZ32C3Clv2k5S31797WcXz6EmkkaNFHcEAetsChyitR7dq6wyzYPxlyRVIBm8lR3fCaIaYcUoGoXaimcIysOgc+RrqvgcXiZ7Hi2yNmtpg0DVzVnYAS5EjSJcGsjcTlFtcNqEl7L1FqP0DqsGwW/sjef1BRzTDB0IMrItiAkV3zvVXE67UwC8l8DtJaveb+KBCvhL2wcBijfilXzIdwBBg7w/rtLaTDFUFqn4WvWk4buoQESbb7WK0KNM9McSPF8OlyNggkgySgoouX70t9POZEGMZyZ0="; asn1Primitive = DSSASN1Utils.toASN1Primitive(Utils.fromBase64(sigTst)); Attribute sigTstsAttibute = new Attribute(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken, new DERSet(asn1Primitive)); assertFalse(D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0MA4GA1UdDwEB/wQEAwIGQDAfBgNVHSMEGDAWgBRCqOm7Hqee0exyCLFux9EparVQwDA7BgNVHR8ENDAyMDCgLqAshipodHRwOi8vY3JsLnF1b3ZhZGlzZ2xvYmFsLmNvbS9xdmV1Y2FnMy5jcmwwHQYDVR0OBBYEFM6QS1LBuAXuLgEbcD7uwVxRNZX4MA0GCSqGSIb3DQEBCwUAA4ICAQBvQC0lq+CzKXkkfYWVlfJBDWFZBf0eY0fGk6leTUMEm5S0m5ACDxKxDRg1h/pL6x6PmjuWS030TjsKUJp4NGMeqbESDd5aXkm2WyVegzKwRaXgDVih/V+cUTAIv7k0xQOMegiFZ4rDD+0HiykmIIFXhOCOo9TbBn7X0je2vHop7YiAXpwjmoZI3tUNlHBSfMmoalXjVc1TTYHFi+5ntUzpLySFnhv7/h16nQQhUXvP37Ob+Ia6EPyOlwz4QeOoBBdUTqhCA3sQjpqvTIRuWp46yoMAZGPEnzB8sB8ddJM/bC0aHcu3viaYZ+tH3UwLOEVs0ebmVouYOhTg543n0u3uXS/ZlgKXSDG7NnUsfg7n717MG94RUQj9FLux7PPENPAaxP9VN8MaX4QQw4ybrVxGlSbZZlcMHL3++U26Nga+Oekasr261b6SAI4ro6amxMIo8pAR38LSwnAbI15mUDv+Ow712yGdf7ezMJkLZp1u/A6WYAsuPU2YbZ7iFofX1ApvGJyDWVv3nVjipjQ/xgcdcKvPwHhaQd4kJ8+LYsiFPehm/7xXSG3dUWkVUgNcAmOzZH10Z9OfPYDJlQgNxJJ+aloYiFtQKuc2+6cT0PwHcMDRICnGKZ+rweMUkI0v9b6fqnZ8OohiSKOVeWwrWqVIKEYZULZryJqdJfZ88LXUoA=="; asn1Primitive = DSSASN1Utils.toASN1Primitive(Utils.fromBase64(certValues)); Attribute certValuesAttibute = new Attribute(PKCSObjectIdentifiers.id_aa_ets_certValues, new DERSet(asn1Primitive)); assertFalse(DSSASN1Utils.isArchiveTimeStampToken(certValuesAttibute)); }
Example #7
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 6 votes |
public static GenSM2KeypairParams getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof GenSM2KeypairParams) { return (GenSM2KeypairParams) obj; } try { if (obj instanceof ASN1Sequence) { return new GenSM2KeypairParams((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse encoded object: " + ex.getMessage(), ex); } }
Example #8
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 6 votes |
public static AddCertParams getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof AddCertParams) { return (AddCertParams) obj; } try { if (obj instanceof ASN1Sequence) { return new AddCertParams((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse object: " + ex.getMessage(), ex); } }
Example #9
Source File: SignatureValidationPolicy.java From signer with GNU Lesser General Public License v3.0 | 6 votes |
public void parse(ASN1Primitive derObject) { ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject); this.signingPeriod = new SigningPeriod(); this.signingPeriod.parse(derSequence.getObjectAt(0).toASN1Primitive()); this.commonRules = new CommonRules(); this.commonRules.parse(derSequence.getObjectAt(1).toASN1Primitive()); this.commitmentRules = new CommitmentRules(); this.commitmentRules.parse(derSequence.getObjectAt(2).toASN1Primitive()); if (derSequence.size() == 4) { this.signPolExtensions = new SignPolExtensions(); this.signPolExtensions.parse(derSequence.getObjectAt(3).toASN1Primitive()); } }
Example #10
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 6 votes |
public static ServerCaps getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof ServerCaps) { return (ServerCaps) obj; } try { if (obj instanceof ASN1Sequence) { return new ServerCaps((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse encoded object: " + ex.getMessage(), ex); } }
Example #11
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 6 votes |
public static NewKeyControl getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof NewKeyControl) { return (NewKeyControl) obj; } try { if (obj instanceof ASN1Sequence) { return new NewKeyControl((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse object: " + ex.getMessage(), ex); } }
Example #12
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 6 votes |
public static GenRSAKeypairParams getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof GenRSAKeypairParams) { return (GenRSAKeypairParams) obj; } try { if (obj instanceof ASN1Sequence) { return new GenRSAKeypairParams((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse encoded object: " + ex.getMessage(), ex); } }
Example #13
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 6 votes |
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new DERUTF8String(control.getLabel())); byte[] id = control.getId(); if (id != null) { vector.add(new DERTaggedObject(0, new DEROctetString(id))); } Set<P11KeyUsage> usages = control.getUsages(); if (CollectionUtil.isNotEmpty(usages)) { ASN1EncodableVector asn1Usages = new ASN1EncodableVector(); for (P11KeyUsage usage : usages) { int value = usageToValueMap.get(usage); asn1Usages.add(new ASN1Enumerated(value)); } vector.add(new DERTaggedObject(1, new DERSequence(asn1Usages))); } if (control.getExtractable() != null) { vector.add(new DERTaggedObject(2, ASN1Boolean.getInstance(control.getExtractable()))); } return new DERSequence(vector); }
Example #14
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 6 votes |
public static GenSecretKeyParams getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof GenSecretKeyParams) { return (GenSecretKeyParams) obj; } try { if (obj instanceof ASN1Sequence) { return new GenSecretKeyParams((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse encoded object: " + ex.getMessage(), ex); } }
Example #15
Source File: XmppDomainVerifier.java From ComplianceTester with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static OtherName parseOtherName(byte[] otherName) { try { ASN1Primitive asn1Primitive = ASN1Primitive.fromByteArray(otherName); if (asn1Primitive instanceof DERTaggedObject) { ASN1Primitive inner = ((DERTaggedObject) asn1Primitive).getObject(); if (inner instanceof DLSequence) { DLSequence sequence = (DLSequence) inner; if (sequence.size() >= 2 && sequence.getObjectAt(1) instanceof DERTaggedObject) { String oid = sequence.getObjectAt(0).toString(); ASN1Primitive value = ((DERTaggedObject) sequence.getObjectAt(1)).getObject(); if (value instanceof DERUTF8String) { return new OtherName(oid, ((DERUTF8String) value).getString()); } else if (value instanceof DERIA5String) { return new OtherName(oid, ((DERIA5String) value).getString()); } } } } return null; } catch (IOException e) { return null; } }
Example #16
Source File: Time.java From signer with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void parse(ASN1Primitive derObject) { if (derObject instanceof ASN1GeneralizedTime) { ASN1GeneralizedTime derGeneralizedTime = (ASN1GeneralizedTime) derObject; try { this.setTime(derGeneralizedTime.getDate()); } catch (ParseException ex) { this.setTime(null); } } else if (derObject instanceof DERUTCTime) { DERUTCTime derUTCTime = (DERUTCTime) derObject; try { this.setTime(derUTCTime.getDate()); } catch (ParseException exception) { this.setTime(null); } } }
Example #17
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 6 votes |
public static NewObjectControl getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof NewObjectControl) { return (NewObjectControl) obj; } try { if (obj instanceof ASN1Sequence) { return new NewObjectControl((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse object: " + ex.getMessage(), ex); } }
Example #18
Source File: X509Ext.java From portecle with GNU General Public License v2.0 | 6 votes |
/** * Get Microsoft CRL Next Publish (1.3.6.1.4.1.311.21.4) extension value as a string. * * @param bValue The octet string value * @return Extension value as a string * @throws IOException If an I/O problem occurs */ private String getMicrosoftCrlNextPublish(byte[] bValue) throws IOException { DERUTCTime time = (DERUTCTime) ASN1Primitive.fromByteArray(bValue); String date = time.getAdjustedTime(); try { date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(time.getAdjustedDate()); } catch (ParseException e) { // Ignored } return escapeHtml(date); }
Example #19
Source File: DERIterator.java From InflatableDonkey with MIT License | 5 votes |
<T extends ASN1Primitive> Optional<T> nextIf(Class<T> is) { if (hasNext() == false) { return Optional.empty(); } ASN1Primitive primitive = DER.asPrimitive(peek()); if (is.isAssignableFrom(primitive.getClass())) { next(); return Optional.ofNullable(is.cast(primitive)); } else { return Optional.empty(); } }
Example #20
Source File: X509Utils.java From acme-client with Apache License 2.0 | 5 votes |
public static String getCACertificateURL(X509Certificate certificate) throws IOException { byte[] bOctets = ((ASN1OctetString) ASN1Primitive.fromByteArray(certificate.getExtensionValue(Extension.authorityInfoAccess.getId()))).getOctets(); AuthorityInformationAccess access = AuthorityInformationAccess.getInstance(ASN1Sequence.fromByteArray(bOctets)); for (AccessDescription ad:access.getAccessDescriptions()){ if (ad.getAccessMethod().equals(X509ObjectIdentifiers.id_ad_caIssuers)){ return ad.getAccessLocation().getName().toString(); } } return null; }
Example #21
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 5 votes |
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(slotId); vector.add(objectId); vector.add(certificate); return new DERSequence(vector); }
Example #22
Source File: DSSASN1Utils.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
/** * Computes SHA-1 hash of the given {@code publicKey}'s * @param publicKey {@link PublicKey} to compute digest for * @return byte array of public key's SHA-1 hash */ public static byte[] computeSkiFromCertPublicKey(final PublicKey publicKey) { try { DLSequence seq = (DLSequence) ASN1Primitive.fromByteArray(publicKey.getEncoded()); DERBitString item = (DERBitString) seq.getObjectAt(1); return DSSUtils.digest(DigestAlgorithm.SHA1, item.getOctets()); } catch (IOException e) { throw new DSSException(e); } }
Example #23
Source File: AuthorizationList.java From android-key-attestation with Apache License 2.0 | 5 votes |
private static Optional<Set<Integer>> findOptionalIntegerSetAuthorizationListEntry( Map<Integer, ASN1Primitive> authorizationMap, int tag) { ASN1Set asn1Set = (ASN1Set) findAuthorizationListEntry(authorizationMap, tag); if (asn1Set == null) { return Optional.empty(); } Set<Integer> entrySet = new HashSet<>(); for (ASN1Encodable value : asn1Set) { entrySet.add(ASN1Parsing.getIntegerFromAsn1(value)); } return Optional.of(entrySet); }
Example #24
Source File: EncryptedKeys.java From InflatableDonkey with MIT License | 5 votes |
public EncryptedKeys(ASN1Primitive primitive) { DERIterator i = DER.asSequence(primitive); Map<Integer, ASN1Primitive> tagged = i.derTaggedObjects(); x = DER.as(ASN1Integer.class, i) .getValue() .intValue(); encryptedKeySet = DER.asSet(i, EncryptedKey::new); cont0 = Optional.ofNullable(tagged.get(CONT0)) .map(DER.as(DEROctetString.class)) .map(ASN1OctetString::getOctets); }
Example #25
Source File: VerifySignature.java From certificate-transparency-java with Apache License 2.0 | 5 votes |
public static List<Ct.SignedCertificateTimestamp> parseSCTsFromCert(X509Certificate leafCert) throws IOException { byte[] bytes = leafCert.getExtensionValue(CTConstants.SCT_CERTIFICATE_OID); List<Ct.SignedCertificateTimestamp> scts = new ArrayList<>(); ASN1Primitive p = ASN1Primitive.fromByteArray(ASN1OctetString.getInstance(bytes).getOctets()); DEROctetString o = (DEROctetString) p; // These are serialized SCTs, we must de-serialize them into an array with one SCT each Ct.SignedCertificateTimestamp[] sctsFromCert = parseSCTsFromCertExtension(o.getOctets()); for (Ct.SignedCertificateTimestamp signedCertificateTimestamp : sctsFromCert) { scts.add(signedCertificateTimestamp); } return scts; }
Example #26
Source File: CAdESWithContentTimestampTest.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected DSSDocument getSignedDocument() { FileDocument fileDocument = new FileDocument("src/test/resources/validation/Signature-C-BES-4.p7m"); try (InputStream is = fileDocument.openStream(); ASN1InputStream asn1sInput = new ASN1InputStream(is)) { ASN1Sequence asn1Seq = (ASN1Sequence) asn1sInput.readObject(); ASN1TaggedObject taggedObj = ASN1TaggedObject.getInstance(asn1Seq.getObjectAt(1)); ASN1Primitive object = taggedObj.getObject(); SignedData signedData = SignedData.getInstance(object); ASN1Set signerInfosAsn1 = signedData.getSignerInfos(); ASN1Sequence seqSignedInfo = ASN1Sequence.getInstance(signerInfosAsn1.getObjectAt(0)); SignerInfo signedInfo = SignerInfo.getInstance(seqSignedInfo); ASN1Set authenticatedAttributes = signedInfo.getAuthenticatedAttributes(); boolean found = false; for (int i = 0; i < authenticatedAttributes.size(); i++) { ASN1Sequence authAttrSeq = ASN1Sequence.getInstance(authenticatedAttributes.getObjectAt(i)); ASN1ObjectIdentifier attrOid = ASN1ObjectIdentifier.getInstance(authAttrSeq.getObjectAt(0)); if (PKCSObjectIdentifiers.id_aa_ets_contentTimestamp.equals(attrOid)) { found = true; } } assertTrue(found); } catch (Exception e) { fail(e); } return fileDocument; }
Example #27
Source File: X509CertificateUtils.java From vespa with Apache License 2.0 | 5 votes |
public static List<SubjectAlternativeName> getSubjectAlternativeNames(X509Certificate certificate) { try { byte[] extensionValue = certificate.getExtensionValue(SUBJECT_ALTERNATIVE_NAMES.getOId()); if (extensionValue == null) return Collections.emptyList(); ASN1Encodable asn1Encodable = ASN1Primitive.fromByteArray(extensionValue); if (asn1Encodable instanceof ASN1OctetString) { asn1Encodable = ASN1Primitive.fromByteArray(((ASN1OctetString) asn1Encodable).getOctets()); } GeneralNames names = GeneralNames.getInstance(asn1Encodable); return SubjectAlternativeName.fromGeneralNames(names); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #28
Source File: ClientIdentity.java From fabric-chaincode-java with Apache License 2.0 | 5 votes |
/** * parseAttributes returns a map of the attributes associated with an identity. * * @param extensionValue DER-encoded Octet string stored in the attributes * extension of the certificate, as a byte array * @return attrMap {Map<String, String>} a map of identity attributes as key * value pair strings * @throws IOException */ private Map<String, String> parseAttributes(final byte[] extensionValue) throws IOException { final Map<String, String> attrMap = new HashMap<String, String>(); // Create ASN1InputStream from extensionValue try (ByteArrayInputStream inStream = new ByteArrayInputStream(extensionValue); ASN1InputStream asn1InputStream = new ASN1InputStream(inStream)) { // Read the DER object final ASN1Primitive derObject = asn1InputStream.readObject(); if (derObject instanceof DEROctetString) { final DEROctetString derOctetString = (DEROctetString) derObject; // Create attributeString from octets and create JSON object final String attributeString = new String(derOctetString.getOctets(), UTF_8); final JSONObject extJSON = new JSONObject(attributeString); final JSONObject attrs = extJSON.getJSONObject("attrs"); final Iterator<String> keys = attrs.keys(); while (keys.hasNext()) { final String key = keys.next(); // Populate map with attributes and values attrMap.put(key, attrs.getString(key)); } } } catch (final JSONException error) { // creating a JSON object failed // decoded extensionValue is not a string containing JSON logger.error(() -> logger.formatError(error)); // return empty map } return attrMap; }
Example #29
Source File: ProxyMessage.java From xipki with Apache License 2.0 | 5 votes |
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(mechanism)); if (params != null) { vector.add(params); } return new DERSequence(vector); }
Example #30
Source File: PrivateKey.java From InflatableDonkey with MIT License | 5 votes |
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = DER.vector( new DEROctetString(privateKey()), publicKeyInfo.orElse(null)); return new DERSequence(vector); }