小编Tom*_*ost的帖子

在Java中解析装甲ECC公钥/私钥(由gpg cli生成)

我正在尝试将装甲ECC gpg密钥转换为相应的java类ECPrivateKey/ECPublicKey.

要生成我正在使用的密钥对: gpg --expert --full-generate-key

然后选择(9)ECC和ECC(或(10)ECC(仅签名))

然后选择(3)NIST P-256

导致:

-----BEGIN PGP PUBLIC KEY BLOCK-----

mFIEWUdzwhMIKoZIzj0DAQcCAwQkAvZC1PIJ8ke1myyKhNny9vN78TIYo2MuAOY+
F38L9S3+Za9cKV/iIHOqfapbMoqdSmSnqDkevwQSr5MF2UOXtCJzaWduZWNjIChF
Q0Mgc2lnbiBvbmx5KSA8c3NAc3MuY28+iJAEExMIADgWIQRiC+kefVkjnjKovKy5
XANFl5+n1gUCWUdzwgIbAwULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRC5XANF
l5+n1mzGAQDsgutymxDTTXPKFfpFFVp4fxacx1MSqxP71gNJYjguXwD8CEXD20Vm
aU1WMi2jU7JC6oJn94Y4vWHwTLOU1zmQ19o=
=swfS
-----END PGP PUBLIC KEY BLOCK-----

-----BEGIN PGP PRIVATE KEY BLOCK-----

lHcEWUdzwhMIKoZIzj0DAQcCAwQkAvZC1PIJ8ke1myyKhNny9vN78TIYo2MuAOY+
F38L9S3+Za9cKV/iIHOqfapbMoqdSmSnqDkevwQSr5MF2UOXAAD9FhS2HZoWOyIi
l9nj+WPa9S1o50jM5bNIRALzcyS8SgoP97Qic2lnbmVjYyAoRUNDIHNpZ24gb25s
eSkgPHNzQHNzLmNvPoiQBBMTCAA4FiEEYgvpHn1ZI54yqLysuVwDRZefp9YFAllH
c8ICGwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQuVwDRZefp9ZsxgEA7ILr
cpsQ001zyhX6RRVaeH8WnMdTEqsT+9YDSWI4Ll8A/AhFw9tFZmlNVjIto1OyQuqC
Z/eGOL1h8EyzlNc5kNfa
=qHBB
-----END PGP PRIVATE KEY BLOCK-----
Run Code Online (Sandbox Code Playgroud)

如何从这种装甲文本格式获得有效的java.security.interfaces.ECPrivateKey和java.security.interfaces.ECPublicKey java类?

我的最终目标是以下列方式登录:

String createSignatureFromJson(String jsonPayload, byte[] privateKey) {
        Payload payload = new Payload(jsonPayload)
        def key = privateKeyParse(privateKey)

        JWSSigner signer = new ECDSASigner((ECPrivateKey)key)
        JWSHeader header = new JWSHeader.Builder(JWSAlgorithm.ES256).build()

        JWSObject jwsObject = new JWSObject(header, payload)
        jwsObject.sign(signer) …
Run Code Online (Sandbox Code Playgroud)

java bouncycastle gnupg elliptic-curve json-web-token

8
推荐指数
2
解决办法
819
查看次数

如何使apt-get使用gpg> 2.1?在Ubuntu 16.4中

我试图在需要GPG版本> 2.1的GPG ECC(NIST P-256)密钥签名的源上使用apt-get

我怎样才能使apt-get使用gpg2代替gpg?(混叠不起作用)

root@fa2e16b8fbc3:/£ gpg --version
gpg (GnuPG) 1.4.20


root@fa2e16b8fbc3:/£ uname -a
Linux fa2e16b8fbc3 4.4.66-boot2docker £1 SMP Fri May 5 20:44:25 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


root@fa2e16b8fbc3:/£ cat /proc/version
Linux version 4.4.66-boot2docker (root@607924cbbc93) (gcc version 4.9.2 (Debian 4.9.2-10) ) £1 SMP Fri May 5 20:44:25 UTC 2017


root@fa2e16b8fbc3:/£ cat /etc/issue
Ubuntu 16.04.3 LTS \n \l

root@fa2e16b8fbc3:/£ apt-get install  gnupg
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gnupg is already the newest version (1.4.20-1ubuntu3.1). …
Run Code Online (Sandbox Code Playgroud)

ubuntu gnupg elliptic-curve

5
推荐指数
0
解决办法
565
查看次数