public static RolesOfPSP getInstance(Object obj) { if (obj instanceof RolesOfPSP) { return (RolesOfPSP) obj; } ASN1Encodable[] array = DERSequence.getInstance(obj).toArray(); RoleOfPSP[] roles = Arrays.stream(array).map(RoleOfPSP::getInstance).toArray(RoleOfPSP[]::new); return new RolesOfPSP(roles); }
public static RolesOfPSP getInstance(Object obj) { if (obj instanceof RolesOfPSP) { return (RolesOfPSP) obj; } ASN1Encodable[] array = DERSequence.getInstance(obj).toArray(); RoleOfPSP[] roles = Arrays.stream(array).map(RoleOfPSP::getInstance).toArray(RoleOfPSP[]::new); return new RolesOfPSP(roles); }
/** * 将DER编码的SM2签名解析成64字节的纯R+S字节流 * * @param derSign * @return */ public static byte[] decodeDERSM2Sign(byte[] derSign) { ASN1Sequence as = DERSequence.getInstance(derSign); byte[] rBytes = ((ASN1Integer) as.getObjectAt(0)).getValue().toByteArray(); byte[] sBytes = ((ASN1Integer) as.getObjectAt(1)).getValue().toByteArray(); //由于大数的补0规则,所以可能会出现33个字节的情况,要修正回32个字节 rBytes = fixToCurveLengthBytes(rBytes); sBytes = fixToCurveLengthBytes(sBytes); byte[] rawSign = new byte[rBytes.length + sBytes.length]; System.arraycopy(rBytes, 0, rawSign, 0, rBytes.length); System.arraycopy(sBytes, 0, rawSign, rBytes.length, sBytes.length); return rawSign; }
protected static PKIXPolicyNode processCertE( CertPath certPath, int index, PKIXPolicyNode validPolicyTree) throws CertPathValidatorException { List certs = certPath.getCertificates(); X509Certificate cert = (X509Certificate)certs.get(index); // // (e) // ASN1Sequence certPolicies = null; try { certPolicies = DERSequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.CERTIFICATE_POLICIES)); } catch (AnnotatedException e) { throw new ExtCertPathValidatorException("Could not read certificate policies extension from certificate.", e, certPath, index); } if (certPolicies == null) { validPolicyTree = null; } return validPolicyTree; }
protected static PKIXPolicyNode processCertE( CertPath certPath, int index, PKIXPolicyNode validPolicyTree) throws CertPathValidatorException { List certs = certPath.getCertificates(); X509Certificate cert = (X509Certificate)certs.get(index); // // (e) // ASN1Sequence certPolicies = null; try { certPolicies = DERSequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.CERTIFICATE_POLICIES)); } catch (AnnotatedException e) { throw new ExtCertPathValidatorException("Could not read certificate policies extension from certificate.", e, certPath, index); } if (certPolicies == null) { validPolicyTree = null; } return validPolicyTree; }
private TLSGostKeyTransportBlob(ASN1Sequence seq) { this.keyBlob = GostR3410KeyTransport.getInstance(seq.getObjectAt(0)); this.proxyKeyBlobs = seq.size() > 1 ? (DERSequence) DERSequence.getInstance(seq.getObjectAt(1)) : null; }
/** * 解DER编码密文(根据《SM2密码算法使用规范》 GM/T 0009-2012) * * @param derCipher * @return */ public static byte[] decodeDERSM2Cipher(byte[] derCipher) { ASN1Sequence as = DERSequence.getInstance(derCipher); byte[] c1x = ((ASN1Integer) as.getObjectAt(0)).getValue().toByteArray(); byte[] c1y = ((ASN1Integer) as.getObjectAt(1)).getValue().toByteArray(); byte[] c3 = ((DEROctetString) as.getObjectAt(2)).getOctets(); byte[] c2 = ((DEROctetString) as.getObjectAt(3)).getOctets(); int pos = 0; byte[] cipherText = new byte[1 + c1x.length + c1y.length + c2.length + c3.length]; final byte uncompressedFlag = 0x04; cipherText[0] = uncompressedFlag; pos += 1; System.arraycopy(c1x, 0, cipherText, pos, c1x.length); pos += c1x.length; System.arraycopy(c1y, 0, cipherText, pos, c1y.length); pos += c1y.length; System.arraycopy(c2, 0, cipherText, pos, c2.length); pos += c2.length; System.arraycopy(c3, 0, cipherText, pos, c3.length); return cipherText; }
public UTF8NameValueSequence(ASN1Sequence sequence) { this.name = DERUTF8String.getInstance(sequence.getObjectAt(0)); this.values = (DERSequence) DERSequence.getInstance(sequence.getObjectAt(1)).getDERObject(); //new DERSequence(sequence.getObjectAt(1)); }
contentsOfAdmissions = DERSequence.getInstance(seq.getObjectAt(0)); break; case 2: admissionAuthority = GeneralName.getInstance(seq.getObjectAt(0)); contentsOfAdmissions = DERSequence.getInstance(seq.getObjectAt(1)); break; default:
private String getSubjectAlternativeNames(final X509Certificate certificate, final int index, final int type) { final byte[] extVal = certificate.getExtensionValue(Extension.issuerAlternativeName.getId()); if (extVal == null) { return null; } try { final Enumeration<?> it = DERSequence.getInstance(X509ExtensionUtil.fromExtensionValue(extVal)).getObjects(); int i = index; while (it.hasMoreElements()) { if (index == i++) { final GeneralName genName = GeneralName.getInstance(it.nextElement()); if (genName.getTagNo() == type) { return ASN1String.class.cast(genName.getName()).getString(); } } } } catch (final IOException e) { // no-op } return null; }
ASN1Sequence isPolicyMappings = DERSequence.getInstance(extensionValue); Map<String, String> isMap = new HashMap<>(); int size = isPolicyMappings.size();
try pc = DERSequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.POLICY_CONSTRAINTS));
try pc = DERSequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.POLICY_CONSTRAINTS));
Enumeration it = DERSequence.getInstance(fromExtensionValue(extVal)).getObjects(); while (it.hasMoreElements())
try pc = DERSequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.POLICY_CONSTRAINTS));
try pc = DERSequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.POLICY_CONSTRAINTS));
try pc = DERSequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.POLICY_CONSTRAINTS));
try pc = DERSequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.POLICY_CONSTRAINTS));
try pm = DERSequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.POLICY_MAPPINGS)); try ASN1Sequence mapping = DERSequence.getInstance(mappings.getObjectAt(j));
private void prepareKeyBlob() throws IOException { SubjectPublicKeyInfo ephemeralKey = null; CustomECPoint ecPoint = msg.getComputations().getClientPublicKey(); if (ecPoint != null) { ephemeralKey = SubjectPublicKeyInfo.getInstance(generatePublicKey(ecPoint).getEncoded()); } Gost2814789EncryptedKey encryptedKey = new Gost2814789EncryptedKey(msg.getComputations().getEncryptedKey() .getValue(), getMaskKey(), msg.getComputations().getMacKey().getValue()); ASN1ObjectIdentifier paramSet = new ASN1ObjectIdentifier(msg.getComputations().getEncryptionParamSet() .getValue()); GostR3410TransportParameters params = new GostR3410TransportParameters(paramSet, ephemeralKey, msg .getComputations().getUkm().getValue()); GostR3410KeyTransport transport = new GostR3410KeyTransport(encryptedKey, params); DERSequence proxyKeyBlobs = (DERSequence) DERSequence.getInstance(getProxyKeyBlobs()); TLSGostKeyTransportBlob blob = new TLSGostKeyTransportBlob(transport, proxyKeyBlobs); msg.setKeyTransportBlob(blob.getEncoded()); LOGGER.debug("GOST key blob: " + ASN1Dump.dumpAsString(blob, true)); }