当我使用OpenSSL生成私有椭圆曲线时,使用以下命令:
openssl ecparam -name secp521r1 -genkey -noout -out key.pem
我得到这样的东西:
-----BEGIN EC PRIVATE KEY-----
MIHbAgEBBEGpyKy6t0i6cEdxETKfsXNmFA4oWLQrM1LaPdfiyGs13+DckCjskukK
NlbQYBb7gKIAAqj4vbmdCjTkoxnuXToqRKAHBgUrgQQAI6GBiQOBhgAEAHRbQ/Ow
rR0fjiLdS+wHgpGX3kIk1IdJwr6m18k8nkta7d6YCho555Tbru+17zrtEMasd5UH
YX8PRRtGaCD29aOzASUXOkwrmth4wLRsDQEe4qWAjATVvbw4LDP9Jz92OFXbEPwR
P3uNunAQ2grnBjNCXN5yF49nyK1lSZxscxv+OCM/
-----END EC PRIVATE KEY-----
与我使用NodeJS的加密模块和密钥编码器混合生成的格式相同:
-----BEGIN EC PRIVATE KEY-----
MIHcAgEBBEIBevCX7Zvo2G93UtPEl2ibpz71dXdjN/xMbwZBQwHukZJWwuKtJ8Sm
dn21nDV5uEa7mgiBu0X5BVvsN/Wr+TzoAD2gBwYFK4EEACOhgYkDgYYABABaycjM
EduL5R+bBY7T5WF+L314mfm2AZkKDs4EDkYWPupzbfE1qsQkjyPjh/JxMRU6nr9w
xJ7X9jSA6wy0dHNqSQFP+5SHOuJu32Da21qBIKU9Xaoy0CloGfRjEQAbg5N1h4uw
wKdMrY2a34dYn1eEe2YFzHKTFJPzOxyeKsDsFaafng==
-----END EC PRIVATE KEY-----
现在,当我使用AES256使用此命令对其进行加密时
openssl ec -aes256 -in key.pem -out encrypted-key.pem
我得到了
-----BEGIN EC PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,96218C0F2D6F661750C994B319DD05FB
pdk5WCaaLL8+YU27QjHMRgNkNwgPfgqL2ZNx/73pBDiSekfEKn39XrllE+j0lEA/
jNt1v85bBl4GQR97Br1wYl0WyHRTMlJvyc1f+dRIG+Pyu2gt4bdWaXbuajn0suWG
EGNPKBQJNvY3+J010FQfVI45puC03gKA910ODSE3igNuAtSxoptmbD9DMr/2hj2y
BG1WarSvtX9P/eFw6sLVtou8iAD53lO41SA/ppHAbwuGdFwH9bA/LKlQUEHC3v2J
QJmEdt/1wYO4QLtFulDpNVd7nqGd3yn2/sZ1E5XBJ4E=
-----END EC PRIVATE KEY-----
如何使用NodeJS'Crypto获得类似加密的密钥?或换句话说,这种格式是什么以及如何加密。使用NodeJS'Crypto很容易进行aes-256-cbc加密,但我不确定如何处理密码(希望pbkdf2)以及如何达到该格式。它是在某处记录的吗?