Lines Matching defs:const

3 const common = require('../common');
7 const assert = require('assert');
8 const crypto = require('crypto');
10 const constants = crypto.constants;
12 const fixtures = require('../common/fixtures');
15 const certPem = fixtures.readKey('rsa_cert.crt');
16 const keyPem = fixtures.readKey('rsa_private.pem');
17 const rsaKeySize = 2048;
18 const rsaPubPem = fixtures.readKey('rsa_public.pem', 'ascii');
19 const rsaKeyPem = fixtures.readKey('rsa_private.pem', 'ascii');
20 const rsaKeyPemEncrypted = fixtures.readKey('rsa_private_encrypted.pem',
22 const dsaPubPem = fixtures.readKey('dsa_public.pem', 'ascii');
23 const dsaKeyPem = fixtures.readKey('dsa_private.pem', 'ascii');
24 const dsaKeyPemEncrypted = fixtures.readKey('dsa_private_encrypted.pem',
26 const rsaPkcs8KeyPem = fixtures.readKey('rsa_private_pkcs8.pem');
27 const dsaPkcs8KeyPem = fixtures.readKey('dsa_private_pkcs8.pem');
29 const ec = new TextEncoder();
31 const openssl1DecryptError = {
40 const decryptError = common.hasOpenSSL3 ?
44 const decryptPrivateKeyError = common.hasOpenSSL3 ? {
54 const input = 'I AM THE WALRUS';
55 const bufferToEncrypt = Buffer.from(input);
56 const bufferPassword = Buffer.from('password');
63 const ab = getBufferCopy(ec.encode(rsaPubPem));
64 const ab2enc = getBufferCopy(bufferToEncrypt);
76 const otherDecrypted = crypto.privateDecrypt(rsaKeyPem, otherEncrypted);
88 const otherDecryptedBufferWithPassword = crypto.privateDecrypt({
152 const plaintext = 'x'.repeat(rsaKeySize / 8);
211 const size = (padding === 'RSA_NO_PADDING') ? rsaKeySize / 8 : 32;
212 const input = Buffer.allocUnsafe(size);
215 const bufferToEncrypt = Buffer.from(input);
219 const encryptedBuffer = crypto.publicEncrypt({
258 const { decryptionTests } =
261 for (const { ct, oaepHash, oaepLabel } of decryptionTests) {
262 const label = oaepLabel ? Buffer.from(oaepLabel, 'hex') : undefined;
263 const copiedLabel = oaepLabel ? getBufferCopy(label) : undefined;
265 const decrypted = crypto.privateDecrypt({
273 const otherDecrypted = crypto.privateDecrypt({
284 for (const fn of [crypto.publicEncrypt, crypto.privateDecrypt]) {
294 for (const oaepHash of [0, false, null, Symbol(), () => {}]) {
305 for (const oaepLabel of [0, false, null, Symbol(), () => {}, {}]) {
323 const expectedSignature = fixtures.readKey(
348 const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'password' };
359 const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'wrong' };
367 const privateKey = fixtures.readKey('rsa_private_b.pem');
368 const publicKey = fixtures.readKey('rsa_public_b.pem');
370 const input = 'I AM THE WALRUS';
372 const signature = fixtures.readKey(
377 const sign = crypto.createSign('SHA256');
380 const output = sign.sign(privateKey, 'hex');
383 const verify = crypto.createVerify('SHA256');
389 const sign2 = crypto.createSign('RSA-SHA256');
392 const output2 = sign2.sign(privateKey, 'hex');
395 const verify2 = crypto.createVerify('SHA256');
406 const input = 'I AM THE WALRUS';
410 const sign = crypto.createSign('SHA1');
412 const signature = sign.sign(dsaKeyPem, 'hex');
414 const verify = crypto.createVerify('SHA1');
420 const sign2 = crypto.createSign('DSS1');
422 const signature2 = sign2.sign(dsaKeyPem, 'hex');
424 const verify2 = crypto.createVerify('DSS1');
435 const input = 'I AM THE WALRUS';
439 const sign = crypto.createSign('SHA1');
441 const signature = sign.sign(dsaPkcs8KeyPem, 'hex');
443 const verify = crypto.createVerify('SHA1');
453 const input = 'I AM THE WALRUS';
456 const sign = crypto.createSign('SHA1');
466 const sign = crypto.createSign('SHA1');
468 const signOptions = { key: dsaKeyPemEncrypted, passphrase: 'password' };
469 const signature = sign.sign(signOptions, 'hex');
471 const verify = crypto.createVerify('SHA1');