本文整理了Java中org.bouncycastle.asn1.x9.X9IntegerConverter
类的一些代码示例,展示了X9IntegerConverter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X9IntegerConverter
类的具体详情如下:
包路径:org.bouncycastle.asn1.x9.X9IntegerConverter
类名称:X9IntegerConverter
[英]A class which converts integers to byte arrays, allowing padding and calculations to be done according the the filed size of the curve or field element involved.
[中]一个将整数转换为字节数组的类,允许根据所涉及的曲线或字段元素的字段大小进行填充和计算。
代码示例来源:origin: web3j/web3j
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
return CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
protected byte[] bigIntToBytes(
BigInteger r)
{
return converter.integerToBytes(r, converter.getByteLength(parameters.getCurve()));
}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
private void populateFromPubKeyInfo(SubjectPublicKeyInfo info)
{
X962Parameters params = X962Parameters.getInstance(info.getAlgorithm().getParameters());
ECCurve curve = EC5Util.getCurve(configuration, params);
ecSpec = EC5Util.convertToSpec(params, curve);
DERBitString bits = info.getPublicKeyData();
byte[] data = bits.getBytes();
ASN1OctetString key = new DEROctetString(data);
//
// extra octet string - one of our old certs...
//
if (data[0] == 0x04 && data[1] == data.length - 2
&& (data[2] == 0x02 || data[2] == 0x03))
{
int qLength = new X9IntegerConverter().getByteLength(curve);
if (qLength >= data.length - 3)
{
try
{
key = (ASN1OctetString) ASN1Primitive.fromByteArray(data);
}
catch (IOException ex)
{
throw new IllegalArgumentException("error recovering public key");
}
}
}
X9ECPoint derQ = new X9ECPoint(curve, key);
this.ecPublicKey = new ECPublicKeyParameters(derQ.getPoint(), ECUtil.getDomainParameters(configuration, params));
}
代码示例来源:origin: BMF-RKSV-Technik/at-registrierkassen-mustercode
/**
* Helper method to convert DER-encoded signature values (e.g. used by Java)
* to concatenated signature values
* (as used by the JWS-standard)
*
* @param derEncodedSignatureValue
* DER-encoded signature value
* @return concatenated signature value (as used by JWS standard)
* @throws IOException
*/
public static byte[] convertDEREncodedSignatureToJWSConcatenated(final byte[] derEncodedSignatureValue)
throws IOException {
final ASN1InputStream asn1InputStream = new ASN1InputStream(derEncodedSignatureValue);
final ASN1Primitive asn1Primitive = asn1InputStream.readObject();
asn1InputStream.close();
final ASN1Sequence asn1Sequence = (ASN1Sequence.getInstance(asn1Primitive));
final ASN1Integer rASN1 = (ASN1Integer) asn1Sequence.getObjectAt(0);
final ASN1Integer sASN1 = (ASN1Integer) asn1Sequence.getObjectAt(1);
final X9IntegerConverter x9IntegerConverter = new X9IntegerConverter();
final byte[] r = x9IntegerConverter.integerToBytes(rASN1.getValue(), 32);
final byte[] s = x9IntegerConverter.integerToBytes(sASN1.getValue(), 32);
final byte[] concatenatedSignatureValue = new byte[64];
System.arraycopy(r, 0, concatenatedSignatureValue, 0, 32);
System.arraycopy(s, 0, concatenatedSignatureValue, 32, 32);
return concatenatedSignatureValue;
}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* FieldElement ::= OCTET STRING
* </pre>
* <p>
* <ol>
* <li> if <i>q</i> is an odd prime then the field element is
* processed as an Integer and converted to an octet string
* according to x 9.62 4.3.1.</li>
* <li> if <i>q</i> is 2<sup>m</sup> then the bit string
* contained in the field element is converted into an octet
* string with the same ordering padded at the front if necessary.
* </li>
* </ol>
*/
public ASN1Primitive toASN1Primitive()
{
int byteCount = converter.getByteLength(f);
byte[] paddedBigInteger = converter.integerToBytes(f.toBigInteger(), byteCount);
return new DEROctetString(paddedBigInteger);
}
}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
&& (data[2] == 0x02 || data[2] == 0x03))
int qLength = new X9IntegerConverter().getByteLength(dParams.getCurve());
代码示例来源:origin: io.github.moacchain/crypto
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
return CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: redfish64/TinyTravelTracker
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* FieldElement ::= OCTET STRING
* </pre>
* <p>
* <ol>
* <li> if <i>q</i> is an odd prime then the field element is
* processed as an Integer and converted to an octet string
* according to x 9.62 4.3.1.</li>
* <li> if <i>q</i> is 2<sup>m</sup> then the bit string
* contained in the field element is converted into an octet
* string with the same ordering padded at the front if necessary.
* </li>
* </ol>
*/
public ASN1Primitive toASN1Primitive()
{
int byteCount = converter.getByteLength(f);
byte[] paddedBigInteger = converter.integerToBytes(f.toBigInteger(), byteCount);
return new DEROctetString(paddedBigInteger);
}
}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
&& (data[2] == 0x02 || data[2] == 0x03))
int qLength = new X9IntegerConverter().getByteLength(curve);
代码示例来源:origin: org.nervos/crypto
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
return CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: com.cryptape.cita/crypto
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
return CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: FISCO-BCOS/web3sdk
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
return CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: org.web3j/crypto
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
return CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: io.daonomic.scalether/util
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
return CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: org.medibloc.panacea/crypto
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(Keys.CURVE.getCurve()));
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
return Keys.CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: kframework/k
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
return CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: neow3j/neow3j
/**
* Decompress a compressed public key (x co-ord and low-bit of y-coord).<br/>
* Based on: https://tools.ietf.org/html/rfc5480#section-2.2
*/
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(NeoConstants.CURVE.getCurve()));
compEnc[0] = (byte) (yBit ? 0x03 : 0x02);
return NeoConstants.CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: CryptoKass/dilithium
/**
* Decompress a compressed public key (x co-ord and low-bit of y-coord).
*
* @param xBN -
* @param yBit -
* @return -
*/
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
compEnc[0] = (byte) (yBit ? 0x03 : 0x02);
return CURVE.getCurve().decodePoint(compEnc);
}
代码示例来源:origin: ZuInnoTe/hadoopcryptoledger
X9IntegerConverter x9 = new X9IntegerConverter();
byte[] compEnc = x9.integerToBytes(x, 1 + x9.getByteLength(CURVE.getCurve()));
boolean yBit=(receiverId & 1) == 1;
compEnc[0] = (byte)(yBit ? 0x03 : 0x02);
内容来源于网络,如有侵权,请联系作者删除!