Skip to content

Commit

Permalink
checkKeyCompatibility: add secp256k1 curve to supported curves
Browse files Browse the repository at this point in the history
We used to allow importing it, and the clients support it.
  • Loading branch information
larabr committed Apr 22, 2024
1 parent 522c51e commit 8ba5c1b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/key/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export function checkKeyCompatibility(publicKey: PublicKey) {
enums.curve.p521,
enums.curve.brainpoolP256r1,
enums.curve.brainpoolP384r1,
enums.curve.brainpoolP512r1
enums.curve.brainpoolP512r1,
enums.curve.secp256k1
]);

if (publicKey.keyPacket.version > 5) {
Expand All @@ -82,7 +83,7 @@ export function checkKeyCompatibility(publicKey: PublicKey) {
const keyAlgo = enums.write(enums.publicKey, keyInfo.algorithm);

if (!supportedPublicKeyAlgorithms.has(keyAlgo)) {
throw new Error('The key algorithm is currently not supported.');
throw new Error(`The key algorithm ${keyInfo.algorithm} is currently not supported.`);
}

if (keyInfo.curve && !supportedCurves.has(keyInfo.curve)) {
Expand Down
2 changes: 1 addition & 1 deletion test/key/check.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Gw0vQaiZn6HGITQw5nBGvXQPF9VpFpsXV9x/08dIdfZLAQVdQowgeBsxCw==
-----END PGP PUBLIC KEY BLOCK-----` });
expect(
() => checkKeyCompatibility(key)
).to.throw(/key algorithm is currently not supported/);
).to.throw(/key algorithm ed25519 is currently not supported/);
});

it('compatibility - it rejects a v6 key', async () => {
Expand Down

0 comments on commit 8ba5c1b

Please sign in to comment.