TritonDataCenter / node-sshpk

Parse, convert, fingerprint and use SSH keys in pure node.js
MIT License
189 stars 50 forks source link

parseKey for ECDSA doesn't retrieve parameters #82

Open Rus1an31 opened 2 years ago

Rus1an31 commented 2 years ago

I'm trying to parse public key with sshpk.parseKey(publicKeyString, 'pem') which has been created with algorithm: "ECDSA" and ecdsaCurve: "P256". Key is of type: -----BEGIN PUBLIC KEY----- Blah-blah-blah -----END PUBLIC KEY-----

var key = sshpk.parseKey(publicKeyString, 'pem');
console.log('Type = ' + key.type);
console.log('Alg = ' + key.alg);
console.log('Kty = ' + key.kty);
console.log('Kid = ' + key.kid);
console.log('Crv = ' + key.crv);
console.log('Use = ' + key.use);
console.log('X = ' + key.x);
console.log('Y = ' + key.y);

When I'm trying to call sshpk.parseKey(publicKeyString, 'pem') and pass public key in publicKeyString it's working without error. But above code returns:

Type = ecdsa
Alg = undefined
Kty = undefined
Kid = undefined
Crv = undefined
Use = undefined
X = undefined
Y = undefined

So values X, Y and others are not initialized. Why all parameters are not initialized?