@Test public void signatureValidation() throws Exception { Tags tags = p.parse(TestAssertions.getExampleRegAssertions()); X509Certificate x509Certificate = X509.parseDer(tags.getTags().get(TagsEnum.TAG_ATTESTATION_CERT.id).value); assertNotNull(x509Certificate); Tag krd = tags.getTags().get(TagsEnum.TAG_UAFV1_KRD.id); Tag signature = tags.getTags().get(TagsEnum.TAG_SIGNATURE.id); byte[] signedBytes = new byte[krd.value.length+4]; System.arraycopy(UnsignedUtil.encodeInt(krd.id), 0, signedBytes, 0, 2); System.arraycopy(UnsignedUtil.encodeInt(krd.length), 0, signedBytes, 2, 2); System.arraycopy(krd.value, 0, signedBytes, 4, krd.value.length); KeyPair keyPair = KeyCodec.getKeyPair(); byte[] signature2 = NamedCurve.sign(signedBytes, keyPair.getPrivate()); BigInteger[] signAndFromatToRS = NamedCurve.signAndFromatToRS(keyPair.getPrivate(), signedBytes); byte[] rawSignatureBytes = Asn1.toRawSignatureBytes(signAndFromatToRS); assertTrue( NamedCurve.checkSignature(keyPair.getPublic(), signedBytes, signature2)); BigInteger[] transformRawSignature = Asn1.transformRawSignature(rawSignatureBytes); assertTrue( NamedCurve.verify(KeyCodec.getKeyAsRawBytes((ECPublicKey)keyPair.getPublic()), signedBytes, transformRawSignature)); assertTrue( NamedCurve.verify(KeyCodec.getKeyAsRawBytes((ECPublicKey)x509Certificate.getPublicKey()), SHA.sha(signedBytes, "SHA256"), Asn1.transformRawSignature(signature.value))); assertTrue( NamedCurve.checkSignature(x509Certificate.getPublicKey(), signedBytes, Asn1.getEncoded(Asn1.transformRawSignature(signature.value)))); }
public static X509Certificate parseDer(byte[] derEncodedCert) throws CertificateException { return parseDer(new ByteArrayInputStream(derEncodedCert)); }
X509 { public static X509Certificate parseDer(byte[] derEncodedCert) throws CertificateException { return parseDer(new ByteArrayInputStream(derEncodedCert)); } }
X509 { public static X509Certificate parseDer(byte[] derEncodedCert) throws CertificateException { return parseDer(new ByteArrayInputStream(derEncodedCert)); }  }
X509 { public static X509Certificate parseDer(byte[] derEncodedCert) throws CertificateException { return parseDer(new ByteArrayInputStream(derEncodedCert)); }  static X509Certificate parseDer(byte[] derEncodedCert); static X509Certificate parseDer(InputStream is); static X509Certificate generateV3Cert(KeyPair pair); static X509Certificate generateV1Cert(KeyPair pair); }
X509 { public static X509Certificate parseDer(byte[] derEncodedCert) throws CertificateException { return parseDer(new ByteArrayInputStream(derEncodedCert)); }  static X509Certificate parseDer(byte[] derEncodedCert); static X509Certificate parseDer(InputStream is); static X509Certificate generateV3Cert(KeyPair pair); static X509Certificate generateV1Cert(KeyPair pair);  }