pkcs1 vs X.509
作者:互联网
X.509(SPKI):java语言定义的秘钥标准
X.509包含pkcs1
rsa-should-i-use-x-509-or-pkcs-
// test data source
KeyStore ks = KeyStore.getInstance("JKS");
ks.load (new FileInputStream (args[0]), args[1].toCharArray());
byte[] spkienc = ks.getCertificate(args[2]).getPublicKey().getEncoded();
System.out.println(DatatypeConverter.printHexBinary(spkienc));
// extract PKCS1 part of original SPKI
byte[] pkcs1enc = SubjectPublicKeyInfo.getInstance(spkienc).parsePublicKey().getEncoded();
System.out.println(DatatypeConverter.printHexBinary(pkcs1enc));
// rebuild SPKI from the PKCS1
AlgorithmIdentifier algid = new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE);
byte[] spki2enc = new SubjectPublicKeyInfo(algid, pkcs1enc).getEncoded();
System.out.println(DatatypeConverter.printHexBinary(spki2enc));
标签:getEncoded,spkienc,vs,System,pkcs1enc,X.509,new,pkcs1,DatatypeConverter 来源: https://www.cnblogs.com/nexusHan/p/15899951.html