Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected static wc2pk11(alg: AesGcmParams, session?: Session): IAlgorithm {
const aad = alg.additionalData ? utils.PrepareData(alg.additionalData) : undefined;
let AesGcmParamsClass = graphene.AesGcmParams;
if (session &&
session.slot.module.cryptokiVersion.major >= 2 &&
session.slot.module.cryptokiVersion.minor >= 40) {
AesGcmParamsClass = graphene.AesGcm240Params;
}
const params = new AesGcmParamsClass(utils.PrepareData(alg.iv), aad, alg.tagLength || 128);
return { name: "AES_GCM", params };
}
protected static wc2pk11(session: graphene.Session, algorithm: Algorithm) {
if (this.isAesGCM(algorithm)) {
const aad = algorithm.additionalData ? utils.prepareData(algorithm.additionalData) : undefined;
let AesGcmParamsClass = graphene.AesGcmParams;
if (session &&
session.slot.module.cryptokiVersion.major >= 2 &&
session.slot.module.cryptokiVersion.minor >= 40) {
AesGcmParamsClass = graphene.AesGcm240Params;
}
const params = new AesGcmParamsClass(utils.prepareData(algorithm.iv), aad, algorithm.tagLength || 128);
return { name: "AES_GCM", params };
} else if (this.isAesCBC(algorithm)) {
return { name: "AES_CBC_PAD", params: utils.prepareData(algorithm.iv) };
} else if (this.isAesECB(algorithm)) {
return { name: "AES_ECB", params: null };
} else {
throw new core.OperationError("Unrecognized algorithm name");
}
}