11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciif (!common.hasCrypto) 41cb0ef41Sopenharmony_ci common.skip('missing crypto'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst crypto = require('crypto'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci// Test case for des-ede3 wrap/unwrap. des3-wrap needs extra 2x blocksize 101cb0ef41Sopenharmony_ci// then plaintext to store ciphertext. 111cb0ef41Sopenharmony_ciconst test = { 121cb0ef41Sopenharmony_ci key: Buffer.from('3c08e25be22352910671cfe4ba3652b1220a8a7769b490ba', 'hex'), 131cb0ef41Sopenharmony_ci iv: Buffer.alloc(0), 141cb0ef41Sopenharmony_ci plaintext: '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBG' + 151cb0ef41Sopenharmony_ci 'WWELweCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZU' + 161cb0ef41Sopenharmony_ci 'JjAfaFg**' 171cb0ef41Sopenharmony_ci}; 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciconst cipher = crypto.createCipheriv('des3-wrap', test.key, test.iv); 201cb0ef41Sopenharmony_ciconst ciphertext = cipher.update(test.plaintext, 'utf8'); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciconst decipher = crypto.createDecipheriv('des3-wrap', test.key, test.iv); 231cb0ef41Sopenharmony_ciconst msg = decipher.update(ciphertext, 'buffer', 'utf8'); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciassert.strictEqual(msg, test.plaintext); 26