Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (chunk: Buffer) => {
const options = {
algorithm: "RSA-SHA256",
privateKey,
signatureLength: 128,
};
const buf = makeMessageChunkSignature(chunk, options); // Buffer
assert(buf instanceof Buffer, "expecting a Buffer");
return buf;
};
}
return function (chunk) {
const options = {
algorithm: "RSA-SHA256",
signatureLength: 128,
privateKey: privateKey
};
const buf = crypto_utils.makeMessageChunkSignature(chunk, options); // Buffer
assert(buf instanceof Buffer, "expecting a Buffer");
return buf;
};
}
function RSAPKCS1V15SHA256_Sign(buffer: Buffer, privateKey: PrivateKeyPEM): Buffer {
// xx if (privateKey instanceof Buffer) {
// xx privateKey = toPem(privateKey, "RSA PRIVATE KEY");
// xx }
const params = {
algorithm: "RSA-SHA256",
privateKey,
signatureLength: rsa_length(privateKey),
};
return makeMessageChunkSignature(buffer, params);
}
signBufferFunc: (chunk: Buffer) => makeMessageChunkSignature(chunk, params),
signatureLength: 128,
signingFunc: function (chunk) {
return crypto_utils.makeMessageChunkSignature(chunk, params);
}
};
function RSAPKCS1V15SHA1_Sign(buffer: Buffer, privateKey: PrivateKeyPEM): Buffer {
assert(!((privateKey as any) instanceof Buffer), "privateKey should not be a Buffer but a PEM");
const params = {
algorithm: "RSA-SHA1",
privateKey,
signatureLength: rsa_length(privateKey),
};
return makeMessageChunkSignature(buffer, params);
}
function RSAPKCS1V15SHA1_Sign(buffer, privateKey) {
if (privateKey instanceof Buffer) {
privateKey = crypto_utils.toPem(privateKey, "RSA PRIVATE KEY");
}
const params = {
signatureLength: crypto_utils.rsa_length(privateKey),
algorithm: "RSA-SHA1",
privateKey: privateKey
};
return crypto_utils.makeMessageChunkSignature(buffer, params);
}
function RSAPKCS1V15SHA256_Sign(buffer, privateKey) {
if (privateKey instanceof Buffer) {
privateKey = crypto_utils.toPem(privateKey, "RSA PRIVATE KEY");
}
const params = {
signatureLength: crypto_utils.rsa_length(privateKey),
algorithm: "RSA-SHA256",
privateKey: privateKey
};
return crypto_utils.makeMessageChunkSignature(buffer, params);
}