Lines Matching defs:const

2 const common = require('../common');
6 const assert = require('assert');
7 const crypto = require('crypto');
9 const constants = crypto.constants;
11 const fixtures = require('../common/fixtures');
14 const certPem = fixtures.readKey('rsa_cert.crt');
15 const keyPem = fixtures.readKey('rsa_private.pem');
16 const rsaKeySize = 2048;
17 const rsaPubPem = fixtures.readKey('rsa_public.pem', 'ascii');
18 const rsaKeyPem = fixtures.readKey('rsa_private.pem', 'ascii');
19 const rsaKeyPemEncrypted = fixtures.readKey('rsa_private_encrypted.pem',
21 const dsaPubPem = fixtures.readKey('dsa_public.pem', 'ascii');
22 const dsaKeyPem = fixtures.readKey('dsa_private.pem', 'ascii');
23 const dsaKeyPemEncrypted = fixtures.readKey('dsa_private_encrypted.pem',
25 const rsaPkcs8KeyPem = fixtures.readKey('rsa_private_pkcs8.pem');
26 const dsaPkcs8KeyPem = fixtures.readKey('dsa_private_pkcs8.pem');
28 const ec = new TextEncoder();
30 const openssl1DecryptError = {
39 const decryptError = common.hasOpenSSL3 ?
43 const decryptPrivateKeyError = common.hasOpenSSL3 ? {
53 const input = 'I AM THE WALRUS';
54 const bufferToEncrypt = Buffer.from(input);
55 const bufferPassword = Buffer.from('password');
62 const ab = getBufferCopy(ec.encode(rsaPubPem));
63 const ab2enc = getBufferCopy(bufferToEncrypt);
75 const otherDecrypted = crypto.privateDecrypt(rsaKeyPem, otherEncrypted);
87 const otherDecryptedBufferWithPassword = crypto.privateDecrypt({
151 const plaintext = 'x'.repeat(rsaKeySize / 8);
210 const size = (padding === 'RSA_NO_PADDING') ? rsaKeySize / 8 : 32;
211 const input = Buffer.allocUnsafe(size);
214 const bufferToEncrypt = Buffer.from(input);
218 const encryptedBuffer = crypto.publicEncrypt({
275 const { decryptionTests } =
278 for (const { ct, oaepHash, oaepLabel } of decryptionTests) {
279 const label = oaepLabel ? Buffer.from(oaepLabel, 'hex') : undefined;
280 const copiedLabel = oaepLabel ? getBufferCopy(label) : undefined;
282 const decrypted = crypto.privateDecrypt({
290 const otherDecrypted = crypto.privateDecrypt({
301 for (const fn of [crypto.publicEncrypt, crypto.privateDecrypt]) {
311 for (const oaepHash of [0, false, null, Symbol(), () => {}]) {
322 for (const oaepLabel of [0, false, null, Symbol(), () => {}, {}]) {
340 const expectedSignature = fixtures.readKey(
365 const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'password' };
376 const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'wrong' };
384 const privateKey = fixtures.readKey('rsa_private_b.pem');
385 const publicKey = fixtures.readKey('rsa_public_b.pem');
387 const input = 'I AM THE WALRUS';
389 const signature = fixtures.readKey(
394 const sign = crypto.createSign('SHA256');
397 const output = sign.sign(privateKey, 'hex');
400 const verify = crypto.createVerify('SHA256');
406 const sign2 = crypto.createSign('RSA-SHA256');
409 const output2 = sign2.sign(privateKey, 'hex');
412 const verify2 = crypto.createVerify('SHA256');
423 const input = 'I AM THE WALRUS';
427 const sign = crypto.createSign('SHA1');
429 const signature = sign.sign(dsaKeyPem, 'hex');
431 const verify = crypto.createVerify('SHA1');
437 const sign2 = crypto.createSign('DSS1');
439 const signature2 = sign2.sign(dsaKeyPem, 'hex');
441 const verify2 = crypto.createVerify('DSS1');
452 const input = 'I AM THE WALRUS';
456 const sign = crypto.createSign('SHA1');
458 const signature = sign.sign(dsaPkcs8KeyPem, 'hex');
460 const verify = crypto.createVerify('SHA1');
470 const input = 'I AM THE WALRUS';
473 const sign = crypto.createSign('SHA1');
483 const sign = crypto.createSign('SHA1');
485 const signOptions = { key: dsaKeyPemEncrypted, passphrase: 'password' };
486 const signature = sign.sign(signOptions, 'hex');
488 const verify = crypto.createVerify('SHA1');