org.bouncycastle.asn1.ASN1BitString Java Examples
The following examples show how to use
org.bouncycastle.asn1.ASN1BitString.
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: Ed25519PrivateKey.java From hedera-sdk-java with Apache License 2.0 | 6 votes |
private static Ed25519PrivateKey fromPrivateKeyInfo(PrivateKeyInfo privateKeyInfo) { Ed25519PrivateKeyParameters privKeyParams; Ed25519PublicKeyParameters pubKeyParams = null; try { ASN1Encodable privateKey = privateKeyInfo.parsePrivateKey(); privKeyParams = new Ed25519PrivateKeyParameters(((ASN1OctetString) privateKey).getOctets(), 0); ASN1BitString pubKeyData = privateKeyInfo.getPublicKeyData(); if (pubKeyData != null) { pubKeyParams = new Ed25519PublicKeyParameters(pubKeyData.getOctets(), 0); } } catch (IOException e) { throw new BadKeyException(e); } if (pubKeyParams != null) { return new Ed25519PrivateKey(privKeyParams, pubKeyParams); } else { return new Ed25519PrivateKey(privKeyParams); } }
Example #2
Source File: SES_SignatureTest.java From ofdrw with Apache License 2.0 | 5 votes |
@Test public void verify() throws IOException, NoSuchAlgorithmException, CertificateException, InvalidKeyException, SignatureException { Path path = Paths.get("src/test/resources", "SignedValue.dat"); Path srcPath = Paths.get("src/test/resources", "Signature.xml"); // Path path = Paths.get("target", "UserV4.esl"); SES_Signature sesSignature = SES_Signature.getInstance(Files.readAllBytes(path)); MessageDigest md = new SM3.Digest(); byte[] digest = md.digest(Files.readAllBytes(srcPath)); final ASN1BitString dataHash = sesSignature.getToSign().getDataHash(); System.out.println(Arrays.equals(digest, dataHash.getOctets())); ASN1OctetString cert = sesSignature.getCert(); CertificateFactory factory = new CertificateFactory(); X509Certificate certificate = (X509Certificate) factory.engineGenerateCertificate(cert.getOctetStream()); TBS_Sign toSign = sesSignature.getToSign(); Signature sg = Signature.getInstance( sesSignature.getSignatureAlgID().toString() , new BouncyCastleProvider()); sg.initVerify(certificate); sg.update(toSign.getEncoded("DER")); byte[] sigVal = sesSignature.getSignature().getBytes(); System.out.println(sg.verify(sigVal)); }
Example #3
Source File: CRLParser.java From dss with GNU Lesser General Public License v2.1 | 4 votes |
private ASN1BitString rebuildASN1BitString(byte[] array) throws IOException { return (ASN1BitString) rebuildASN1Primitive(BERTags.BIT_STRING, array); }