mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-06-09 07:36:42 +00:00
Detect unexpected eddsaLegacy OID on parsing
This commit is contained in:
parent
f8d0e6052f
commit
52611e7f26
@ -171,6 +171,9 @@ export function parsePublicKeyParams(algo, bytes) {
|
||||
case enums.publicKey.eddsaLegacy: {
|
||||
const oid = new OID(); read += oid.read(bytes);
|
||||
checkSupportedCurve(oid);
|
||||
if (oid.getName() !== enums.curve.ed25519Legacy) {
|
||||
throw new Error('Unexpected OID for eddsaLegacy');
|
||||
}
|
||||
let Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
|
||||
Q = util.leftPad(Q, 33);
|
||||
return { read: read, publicParams: { oid, Q } };
|
||||
@ -227,6 +230,9 @@ export function parsePrivateKeyParams(algo, bytes, publicParams) {
|
||||
}
|
||||
case enums.publicKey.eddsaLegacy: {
|
||||
const payloadSize = getCurvePayloadSize(algo, publicParams.oid);
|
||||
if (publicParams.oid.getName() !== enums.curve.ed25519Legacy) {
|
||||
throw new Error('Unexpected OID for eddsaLegacy');
|
||||
}
|
||||
let seed = util.readMPI(bytes.subarray(read)); read += seed.length + 2;
|
||||
seed = util.leftPad(seed, payloadSize);
|
||||
return { read, privateParams: { seed } };
|
||||
|
Loading…
x
Reference in New Issue
Block a user