• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3if (!common.hasCrypto)
4  common.skip('missing crypto');
5
6const assert = require('assert');
7const crypto = require('crypto');
8
9// Test case for des-ede3 wrap/unwrap. des3-wrap needs extra 2x blocksize
10// then plaintext to store ciphertext.
11const test = {
12  key: Buffer.from('3c08e25be22352910671cfe4ba3652b1220a8a7769b490ba', 'hex'),
13  iv: Buffer.alloc(0),
14  plaintext: '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBG' +
15    'WWELweCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZU' +
16    'JjAfaFg**'
17};
18
19const cipher = crypto.createCipheriv('des3-wrap', test.key, test.iv);
20const ciphertext = cipher.update(test.plaintext, 'utf8');
21
22const decipher = crypto.createDecipheriv('des3-wrap', test.key, test.iv);
23const msg = decipher.update(ciphertext, 'buffer', 'utf8');
24
25assert.strictEqual(msg, test.plaintext);
26