本文整理匯總了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();
}