use of com.github.zhenwei.provider.jce.provider.WeGooProvider in project LinLong-Java by zhenwei1108.
the class P10Test method genP10.
@Test
public void genP10() throws Exception {
WeGooProvider provider = new WeGooProvider();
KeyBuilder keyBuilder = new KeyBuilder(provider);
KeyPair keyPair = keyBuilder.buildKeyPair(KeyPairAlgEnum.SM2_256);
List<CertExtension> list = new ArrayList<>();
CertExtension certExtension = new CertExtension("1.2.3", "demo1111".getBytes(StandardCharsets.UTF_8), CodingType.DEROCTETSTRING);
list.add(certExtension);
P10Builder p10Builder = new P10Builder("C=CN,CN=TEST", keyPair.getPublic(), keyPair.getPrivate(), list);
String p10 = p10Builder.getP10();
System.out.println(p10);
}
use of com.github.zhenwei.provider.jce.provider.WeGooProvider in project LinLong-Java by zhenwei1108.
the class RealHashTest method sm3Digest.
@Test
public void sm3Digest() throws BaseWeGooException {
WeGooProvider provider = new WeGooProvider();
HashBuilder builder = new HashBuilder(provider);
byte[] source = "asdf".getBytes(StandardCharsets.UTF_8);
byte[] digest = builder.digest(DigestAlgEnum.SM3, source);
System.out.println(Hex.toHexString(digest));
// 公钥参与运算
KeyBuilder keyBuilder = new KeyBuilder(provider);
KeyPair keyPair = keyBuilder.buildKeyPair(KeyPairAlgEnum.SM2_256);
DigestParams digestParams = new DigestParams(keyPair.getPublic());
digest = builder.digest(DigestAlgEnum.SM3, source, digestParams);
System.out.println(Hex.toHexString(digest));
}
use of com.github.zhenwei.provider.jce.provider.WeGooProvider in project LinLong-Java by zhenwei1108.
the class RealSignerTest method readSigner.
@Test
public void readSigner() throws BaseWeGooException {
WeGooProvider weGooProvider = new WeGooProvider();
SignBuilder signBuilder = new SignBuilder(weGooProvider);
KeyBuilder keyBuilder = new KeyBuilder(weGooProvider);
KeyPair keyPair = keyBuilder.buildKeyPair(KeyPairAlgEnum.RSA_1024);
byte[] data = signBuilder.signatureSourceData(SignAlgEnum.SHA256_WITH_RSA, keyPair.getPrivate(), "asdfa".getBytes(StandardCharsets.UTF_8));
System.out.println(Hex.toHexString(data));
}
Aggregations