本文整理汇总了Java中org.bouncycastle.asn1.DEROctetString.getOctets方法的典型用法代码示例。如果您正苦于以下问题:Java DEROctetString.getOctets方法的具体用法?Java DEROctetString.getOctets怎么用?Java DEROctetString.getOctets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.DEROctetString
的用法示例。
在下文中一共展示了DEROctetString.getOctets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decrypt
import org.bouncycastle.asn1.DEROctetString; //导入方法依赖的package包/类
public static byte[] decrypt(byte[] privateKey, byte[] encryptedData) throws IOException {
if (privateKey == null || privateKey.length == 0) {
return null;
}
if (encryptedData == null || encryptedData.length == 0) {
return null;
}
byte[] enc = new byte[encryptedData.length];
System.arraycopy(encryptedData, 0, enc, 0, encryptedData.length);
SM2 sm2 = SM2.Instance();
BigInteger userD = new BigInteger(1, privateKey);
ByteArrayInputStream bis = new ByteArrayInputStream(enc);
ASN1InputStream dis = new ASN1InputStream(bis);
DERObject derObj = dis.readObject();
ASN1Sequence asn1 = (ASN1Sequence) derObj;
DERInteger x = (DERInteger) asn1.getObjectAt(0);
DERInteger y = (DERInteger) asn1.getObjectAt(1);
ECPoint c1 = sm2.ecc_curve.createPoint(x.getValue(), y.getValue(), true);
Cipher cipher = new Cipher();
cipher.initDec(userD, c1);
DEROctetString data = (DEROctetString) asn1.getObjectAt(3);
enc = data.getOctets();
cipher.decrypt(enc);
byte[] c3 = new byte[32];
cipher.dofinal(c3);
return enc;
}
示例2: removingTagAndLenFromExtensionValue
import org.bouncycastle.asn1.DEROctetString; //导入方法依赖的package包/类
private static byte[] removingTagAndLenFromExtensionValue(byte[] encodedExtensionValue) {
DEROctetString derOctet = (DEROctetString) DEROctetString.getInstance(
encodedExtensionValue);
return derOctet.getOctets();
}