Check signature public key algorithm against issuer key algorithm
This commit is contained in:
parent
3b9676f2e9
commit
8720adcf65
|
@ -62,6 +62,11 @@ function PublicKey(date=new Date()) {
|
||||||
* @type {Date}
|
* @type {Date}
|
||||||
*/
|
*/
|
||||||
this.created = util.normalizeDate(date);
|
this.created = util.normalizeDate(date);
|
||||||
|
/**
|
||||||
|
* Public key algorithm.
|
||||||
|
* @type {String}
|
||||||
|
*/
|
||||||
|
this.algorithm = null;
|
||||||
/**
|
/**
|
||||||
* Algorithm specific params
|
* Algorithm specific params
|
||||||
* @type {Array<Object>}
|
* @type {Array<Object>}
|
||||||
|
|
|
@ -52,7 +52,10 @@ function PublicKeyEncryptedSessionKey() {
|
||||||
this.version = 3;
|
this.version = 3;
|
||||||
|
|
||||||
this.publicKeyId = new type_keyid();
|
this.publicKeyId = new type_keyid();
|
||||||
|
this.publicKeyAlgorithm = null;
|
||||||
|
|
||||||
this.sessionKey = null;
|
this.sessionKey = null;
|
||||||
|
this.sessionKeyAlgorithm = null;
|
||||||
|
|
||||||
/** @type {Array<module:type/mpi>} */
|
/** @type {Array<module:type/mpi>} */
|
||||||
this.encrypted = [];
|
this.encrypted = [];
|
||||||
|
|
|
@ -666,6 +666,10 @@ Signature.prototype.verify = async function (key, signatureType, data) {
|
||||||
const publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm);
|
const publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm);
|
||||||
const hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm);
|
const hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm);
|
||||||
|
|
||||||
|
if (publicKeyAlgorithm !== enums.write(enums.publicKey, key.algorithm)) {
|
||||||
|
throw new Error('Public key algorithm used to sign signature does not match issuer key algorithm.');
|
||||||
|
}
|
||||||
|
|
||||||
let toHash;
|
let toHash;
|
||||||
let hash;
|
let hash;
|
||||||
if (this.hashed) {
|
if (this.hashed) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user