Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkKeyCompatibility: reject v5 keys #202

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/key/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function checkKeyCompatibility(publicKey: PublicKey) {
enums.curve.secp256k1
]);

if (publicKey.keyPacket.version > 5) {
if (publicKey.keyPacket.version > 4) {
throw new Error(`Version ${publicKey.keyPacket.version} keys are currently not supported.`);
}

Expand Down
27 changes: 27 additions & 0 deletions test/key/check.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,33 @@ Gw0vQaiZn6HGITQw5nBGvXQPF9VpFpsXV9x/08dIdfZLAQVdQowgeBsxCw==
).to.throw(/key algorithm ed25519 is currently not supported/);
});

it('compatibility - it rejects a v5 key', async () => {
const key = await readKey({
armoredKey: `-----BEGIN PGP PRIVATE KEY BLOCK-----

xYwFZC7tvxYAAAAtCSsGAQQB2kcPAQEHQP/d1oBAqCKZYxb6k8foyX2Aa/VK
dHFymZPGvHRk1ncs/R0JAQMIrDnS3Bany9EAF6dwQSfPSdObc4ROYIMAnwAA
ADKV1OhGzwANnapimvODI6fK5F7/V0GxETY9WmnipnBzr4Fe9GZw4QD4Q4hd
IJMawjUBrs0MdjVAYWVhZC50ZXN0wpIFEBYKAEQFgmQu7b8ECwkHCAMVCAoE
FgACAQIZAQKbAwIeByKhBQ/Y89PNwfdXUdI/td5Q9rNrYP9mb7Dg6k/3nxTg
ugQ5AyIBAgAAf0kBAJv0OQvd4u8R0f3HAsmQeqMnwNA4or75BOn/ieApNZUt
AP9kQVmYEk4+MV57Us15l2kQEslLDr3qiH5+VCICdEprB8eRBWQu7b8SAAAA
MgorBgEEAZdVAQUBAQdA4IgEkfze3eNKRz6DgzGSJxw/CV/5Rp5u4Imn47h7
pyADAQgH/R0JAQMIwayD3R4E0ugAyszSmOIpaLJ40YGBp5uU7wAAADKmSv4W
tio7GfZCVl8eJ7xX3J1b0iMvEm876tUeHANQlYYCWz+2ahmPVe79zzZA9OhN
FcJ6BRgWCAAsBYJkLu2/ApsMIqEFD9jz083B91dR0j+13lD2s2tg/2ZvsODq
T/efFOC6BDkAAHcjAPwIPNHnR9bKmkVop6cE05dCIpZ/W8zXDGnjKYrrC4Hb
4gEAmISD1GRkNOmCV8aHwN5svO6HuwXR4cR3o3l7HlYeag8=
=wpkQ
-----END PGP PRIVATE KEY BLOCK-----`,
// @ts-expect-error missing `config.enableParsingV5Entities` declaration
config: { enableParsingV5Entities: true }
});
expect(
() => checkKeyCompatibility(key)
).to.throw(/Version 5 keys are currently not supported/);
});

it('compatibility - it rejects a v6 key', async () => {
const key = await readKey({ armoredKey: `-----BEGIN PGP PUBLIC KEY BLOCK-----

Expand Down
Loading