diff options
author | Marvin W <git@larma.de> | 2017-03-11 01:29:38 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-03-11 23:59:04 +0100 |
commit | d5ea5172a754848c10d061a4a9dd777f63ba71c1 (patch) | |
tree | aeb7694b93158e23714f481a5cdfb5c87b59b630 /plugins/signal-protocol/tests/hkdf.vala | |
parent | e27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9 (diff) | |
download | dino-d5ea5172a754848c10d061a4a9dd777f63ba71c1.tar.gz dino-d5ea5172a754848c10d061a4a9dd777f63ba71c1.zip |
Add OMEMO via Plugin
Diffstat (limited to 'plugins/signal-protocol/tests/hkdf.vala')
-rw-r--r-- | plugins/signal-protocol/tests/hkdf.vala | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/signal-protocol/tests/hkdf.vala b/plugins/signal-protocol/tests/hkdf.vala new file mode 100644 index 00000000..c30af275 --- /dev/null +++ b/plugins/signal-protocol/tests/hkdf.vala @@ -0,0 +1,59 @@ +namespace Signal.Test { + +class HKDF : Gee.TestCase { + + public HKDF() { + base("HKDF"); + add_test("vector_v3", test_hkdf_vector_v3); + } + + private Context global_context; + + public override void set_up() { + try { + global_context = new Context(); + } catch (Error e) { + fail_if_reached(); + } + } + + public override void tear_down() { + global_context = null; + } + + public void test_hkdf_vector_v3() { + uint8[] ikm = { + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}; + + uint8[] salt = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c}; + + uint8[] info = { + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9}; + + uint8[] okm = { + 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, + 0x90, 0x43, 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a, + 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, 0x5a, 0x4c, + 0x5d, 0xb0, 0x2d, 0x56, 0xec, 0xc4, 0xc5, 0xbf, + 0x34, 0x00, 0x72, 0x08, 0xd5, 0xb8, 0x87, 0x18, + 0x58, 0x65}; + + NativeHkdfContext context = null; + fail_if_not_zero_int(NativeHkdfContext.create(out context, 3, global_context.native_context)); + + uint8[] output = null; + int result = (int) context.derive_secrets(out output, ikm, salt, info, 42); + fail_if_not_eq_int(result, okm.length); + output.length = result; + + fail_if_not_eq_uint8_arr(output, okm); + } + +} + +}
\ No newline at end of file |