aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/unittest/crypto/aes_gcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/unittest/crypto/aes_gcm.c')
-rw-r--r--src/plugins/unittest/crypto/aes_gcm.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/plugins/unittest/crypto/aes_gcm.c b/src/plugins/unittest/crypto/aes_gcm.c
new file mode 100644
index 00000000000..826979e74e7
--- /dev/null
+++ b/src/plugins/unittest/crypto/aes_gcm.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Test vectors published in GCM Specification */
+
+#include <vppinfra/clib.h>
+#include <vnet/crypto/crypto.h>
+#include <unittest/crypto/crypto.h>
+
+static u8 tc6_iv[] = {
+ 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
+ 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
+ 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
+ 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
+ 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
+ 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
+ 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
+ 0xa6, 0x37, 0xb3, 0x9b
+};
+
+static u8 tc6_plaintext[] = {
+ 0xd9, 0x31, 0x32, 0x25,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0xfa,
+ 0x46, 0x2a, 0xf4, 0x3c, 0x16, 0x99, 0xd0, 0x50,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (aes_gcm_tc6) = {
+ .name = "GCM Spec. TC6",
+ .alg = VNET_CRYPTO_ALG_AES_128_GCM,
+ .iv = TEST_DATA (tc6_iv),
+ .key = TEST_DATA (tc6_key),
+ .plaintext = TEST_DATA (tc6_plaintext),
+ .ciphertext = TEST_DATA (tc6_ciphertext),
+ .tag = TEST_DATA (tc6_tag),
+ .aad = TEST_DATA (tc6_aad),
+};
+
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */