AES Key Wrap Segfault

CC @thelunararmy

  • Version: 6.11.2
  • Platform: Linux PCName 4.8.0-56-generic # 61~16.04.1-Ubuntu SMP Wed Jun 14 11:58:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: crypto -> ciphers -> id-aesXXX-wrap

We're trying to do aes key wrapping for our nodejs webcrypto implementation. We were having some trouble so we made the following test script (using data from RFC3394):

'use strict'

const crypto = require('crypto')

let cipherName = 'id-aes128-wrap'

// Ripped from RFC3394
let kekHex = '000102030405060708090A0B0C0D0E0F' // for 256: '000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F'
let keyHex = '00112233445566778899AABBCCDDEEFF' // for 256: '00112233445566778899AABBCCDDEEFF000102030405060708090A0B0C0D0E0F'
let ivHex = 'A6A6A6A6A6A6A6A6'

let iv = Buffer.from(ivHex, 'hex')
let kek = Buffer.from(kekHex, 'hex')
let key = Buffer.from(keyHex, 'hex')

try {
  let cipher = crypto.createCipheriv(cipherName, kek, iv)
  let result = cipher.update(key)
  let final = cipher.final()

  // TODO process result

  console.log('RESULT', result, final)
} catch (error) {
  console.error('ERROR', error)
}

Running this script causes node to segfault. Any ideas?