Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/openssl/ossl_cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
(ctx) = EVP_CIPHER_CTX_new(); \
if (!(ctx)) \
ossl_raise(rb_eRuntimeError, NULL); \
EVP_CIPHER_CTX_set_flags((ctx), EVP_CIPHER_CTX_FLAG_WRAP_ALLOW); \
RTYPEDDATA_DATA(obj) = (ctx); \
} while (0)
#define GetCipher(obj, ctx) do { \
Expand Down
12 changes: 12 additions & 0 deletions test/openssl/test_cipher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,18 @@ def test_aes_gcm_key_iv_order_issue
assert_equal tag1, tag2
end

def test_aes_keywrap
# RFC 3394 Section 4.1
kek = ["000102030405060708090a0b0c0d0e0f"].pack("H*")
key = ["00112233445566778899aabbccddeeff"].pack("H*")
wrap = ["1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5"].pack("H*")

cipher = new_encryptor("id-aes128-wrap", key: kek)
assert_equal wrap, cipher.update(key) << cipher.final
cipher = new_decryptor("id-aes128-wrap", key: kek)
assert_equal key, cipher.update(wrap) << cipher.final
end if has_cipher?("id-aes128-wrap")

def test_aes_keywrap_pad
# RFC 5649 Section 6; The second example
kek = ["5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8"].pack("H*")
Expand Down