/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2017-2020, Regents of the University of California.
 *
 * This file is part of ndncert, a certificate management system based on NDN.
 *
 * ndncert is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *
 * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received copies of the GNU General Public License along with
 * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 *
 * See AUTHORS.md for complete list of ndncert authors and contributors.
 */

#include "detail/crypto-helper.hpp"
#include "test-common.hpp"

namespace ndn {
namespace ndncert {
namespace tests {

BOOST_AUTO_TEST_SUITE(TestCryptoHelper)

BOOST_AUTO_TEST_CASE(EcdhWithRawKey)
{
  ECDHState aliceState;
  auto alicePub = aliceState.getRawSelfPubKey();
  BOOST_CHECK(aliceState.m_publicKeyLen != 0);

  ECDHState bobState;
  auto bobPub = bobState.getRawSelfPubKey();
  BOOST_CHECK(bobState.m_publicKeyLen != 0);

  auto aliceResult = aliceState.deriveSecret(bobPub, bobState.m_publicKeyLen);

  BOOST_CHECK(aliceState.m_sharedSecretLen != 0);

  auto bobResult = bobState.deriveSecret(alicePub, aliceState.m_publicKeyLen);

  BOOST_CHECK(bobState.m_sharedSecretLen != 0);

  BOOST_CHECK_EQUAL_COLLECTIONS(aliceResult, aliceResult + 32, bobResult, bobResult + 32);
}

BOOST_AUTO_TEST_CASE(EcdhWithRawKeyWrongInput)
{
  ECDHState aliceState;
  auto alicePub = aliceState.getRawSelfPubKey();
  BOOST_CHECK(alicePub != nullptr);
  BOOST_CHECK(aliceState.m_publicKeyLen != 0);
  uint8_t fakePub[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b};
  BOOST_CHECK_THROW(aliceState.deriveSecret(fakePub, sizeof(fakePub)), std::runtime_error);
}

BOOST_AUTO_TEST_CASE(EcdhWithBase64Key)
{
  ECDHState aliceState;
  auto alicePub = aliceState.getBase64PubKey();
  BOOST_CHECK(alicePub != "");

  ECDHState bobState;
  auto bobPub = bobState.getBase64PubKey();
  BOOST_CHECK(bobPub != "");

  auto aliceResult = aliceState.deriveSecret(bobPub);
  BOOST_CHECK(aliceState.m_sharedSecretLen != 0);

  auto bobResult = bobState.deriveSecret(alicePub);
  BOOST_CHECK(bobState.m_sharedSecretLen != 0);

  BOOST_CHECK_EQUAL_COLLECTIONS(aliceResult, aliceResult + 32, bobResult, bobResult + 32);
}

BOOST_AUTO_TEST_CASE(HmacSha256)
{
  // RFC5869 appendix A.1, IKM, Salt -> PRK
  const uint8_t ikm[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
                         0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
                         0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b};
  const uint8_t salt[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                          0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c};
  const uint8_t expected[] = {0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf,
                              0x0d, 0xdc, 0x3f, 0x0d, 0xc4, 0x7b, 0xba, 0x63,
                              0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f, 0x9c, 0x31,
                              0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5};
  uint8_t result[32];
  hmac_sha256(ikm, sizeof(ikm), salt, sizeof(salt), result);
  BOOST_CHECK_EQUAL_COLLECTIONS(result, result + sizeof(result), expected,
                                expected + sizeof(expected));
}

BOOST_AUTO_TEST_CASE(Hkdf1)
{
  // RFC5869 appendix A.1
  const uint8_t ikm[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
                         0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
                         0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b};
  const uint8_t salt[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                          0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c};
  const uint8_t info[] = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4,
                          0xf5, 0xf6, 0xf7, 0xf8, 0xf9};
  const uint8_t expected[] = {
      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};
  uint8_t result[42];
  auto resultLen = hkdf(ikm, sizeof(ikm), salt, sizeof(salt), result,
                        sizeof(result), info, sizeof(info));

  BOOST_CHECK_EQUAL(resultLen, sizeof(result));
  BOOST_CHECK_EQUAL_COLLECTIONS(result, result + sizeof(result), expected,
                                expected + sizeof(expected));
}

BOOST_AUTO_TEST_CASE(Hkdf2)
{
  // RFC5869 appendix A.2
  const uint8_t ikm[] = {
      0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
      0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
      0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
      0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
      0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
      0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f};
  const uint8_t salt[] = {
      0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
      0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
      0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83,
      0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
      0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
      0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
      0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf};
  const uint8_t info[] = {
      0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb,
      0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
      0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3,
      0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
      0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
      0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
      0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff};
  const uint8_t expected[] = {
      0xb1, 0x1e, 0x39, 0x8d, 0xc8, 0x03, 0x27, 0xa1, 0xc8, 0xe7, 0xf7, 0x8c,
      0x59, 0x6a, 0x49, 0x34, 0x4f, 0x01, 0x2e, 0xda, 0x2d, 0x4e, 0xfa, 0xd8,
      0xa0, 0x50, 0xcc, 0x4c, 0x19, 0xaf, 0xa9, 0x7c, 0x59, 0x04, 0x5a, 0x99,
      0xca, 0xc7, 0x82, 0x72, 0x71, 0xcb, 0x41, 0xc6, 0x5e, 0x59, 0x0e, 0x09,
      0xda, 0x32, 0x75, 0x60, 0x0c, 0x2f, 0x09, 0xb8, 0x36, 0x77, 0x93, 0xa9,
      0xac, 0xa3, 0xdb, 0x71, 0xcc, 0x30, 0xc5, 0x81, 0x79, 0xec, 0x3e, 0x87,
      0xc1, 0x4c, 0x01, 0xd5, 0xc1, 0xf3, 0x43, 0x4f, 0x1d, 0x87};

  uint8_t result[82];
  auto resultLen = hkdf(ikm, sizeof(ikm), salt, sizeof(salt), result,
                        sizeof(result), info, sizeof(info));

  BOOST_CHECK_EQUAL(resultLen, sizeof(result));
  BOOST_CHECK_EQUAL_COLLECTIONS(result, result + sizeof(result), expected,
                                expected + sizeof(expected));
}

BOOST_AUTO_TEST_CASE(Hkdf3)
{
  // RFC5869 appendix A.3
  const uint8_t ikm[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
                         0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
                         0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b};
  const uint8_t expected[] = {
      0x8d, 0xa4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f, 0x71, 0x5f, 0x80,
      0x2a, 0x06, 0x3c, 0x5a, 0x31, 0xb8, 0xa1, 0x1f, 0x5c, 0x5e, 0xe1,
      0x87, 0x9e, 0xc3, 0x45, 0x4e, 0x5f, 0x3c, 0x73, 0x8d, 0x2d, 0x9d,
      0x20, 0x13, 0x95, 0xfa, 0xa4, 0xb6, 0x1a, 0x96, 0xc8};
  uint8_t result[42];

  auto resultLen = hkdf(ikm, sizeof(ikm), nullptr, 0, result,
                        sizeof(result), nullptr, 0);

  BOOST_CHECK_EQUAL(resultLen, sizeof(result));
  BOOST_CHECK_EQUAL_COLLECTIONS(result, result + sizeof(result), expected,
                                expected + sizeof(expected));
}

BOOST_AUTO_TEST_CASE(AesGcm1)
{
  // Test case from NIST Cryptographic Algorithm Validation Program
  // https://csrc.nist.gov/Projects/cryptographic-algorithm-validation-program/CAVP-TESTING-BLOCK-CIPHER-MODES
  // Count = 0
  // Key = cf063a34d4a9a76c2c86787d3f96db71
  // IV = 113b9785971864c83b01c787
  // CT =
  // AAD =
  // Tag = 72ac8493e3a5228b5d130a69d2510e42
  // PT =
  const uint8_t key[] = {0xcf, 0x06, 0x3a, 0x34, 0xd4, 0xa9, 0xa7, 0x6c,
                         0x2c, 0x86, 0x78, 0x7d, 0x3f, 0x96, 0xdb, 0x71};
  const uint8_t iv[] = {0x11, 0x3b, 0x97, 0x85, 0x97, 0x18,
                        0x64, 0xc8, 0x3b, 0x01, 0xc7, 0x87};
  const uint8_t expected_tag[] = {0x72, 0xac, 0x84, 0x93, 0xe3, 0xa5,
                                  0x22, 0x8b, 0x5d, 0x13, 0x0a, 0x69,
                                  0xd2, 0x51, 0x0e, 0x42};

  uint8_t ciphertext[256] = {0};
  uint8_t tag[16] = {0};
  const uint8_t empty_buffer[1] = {0};
  int size = aes_gcm_128_encrypt(empty_buffer, 0, empty_buffer, 0, key, iv, ciphertext, tag);
  BOOST_CHECK(size == 0);
  BOOST_CHECK_EQUAL_COLLECTIONS(tag, tag + 16, expected_tag, expected_tag + sizeof(expected_tag));

  uint8_t decrypted[256] = {0};
  size = aes_gcm_128_decrypt(ciphertext, size, empty_buffer, 0, tag, key, iv, decrypted);
  BOOST_CHECK(size == 0);
}

BOOST_AUTO_TEST_CASE(AesGcm2)
{
  // Test case from NIST Cryptographic Algorithm Validation Program
  // https://csrc.nist.gov/Projects/cryptographic-algorithm-validation-program/CAVP-TESTING-BLOCK-CIPHER-MODES
  // Count = 1
  // Key = 2370e320d4344208e0ff5683f243b213
  // IV = 04dbb82f044d30831c441228
  // CT =
  // AAD = d43a8e5089eea0d026c03a85178b27da
  // Tag = 2a049c049d25aa95969b451d93c31c6e
  // PT =
  const uint8_t key[] = {0x23, 0x70, 0xe3, 0x20, 0xd4, 0x34, 0x42, 0x08,
                         0xe0, 0xff, 0x56, 0x83, 0xf2, 0x43, 0xb2, 0x13};
  const uint8_t iv[] = {0x04, 0xdb, 0xb8, 0x2f, 0x04, 0x4d,
                        0x30, 0x83, 0x1c, 0x44, 0x12, 0x28};
  const uint8_t aad[] = {0xd4, 0x3a, 0x8e, 0x50, 0x89, 0xee, 0xa0, 0xd0,
                         0x26, 0xc0, 0x3a, 0x85, 0x17, 0x8b, 0x27, 0xda};
  const uint8_t expected_tag[] = {0x2a, 0x04, 0x9c, 0x04, 0x9d, 0x25,
                                  0xaa, 0x95, 0x96, 0x9b, 0x45, 0x1d,
                                  0x93, 0xc3, 0x1c, 0x6e};

  uint8_t ciphertext[256] = {0};
  uint8_t tag[16] = {0};
  const uint8_t empty_buffer[1] = {0};
  int size = aes_gcm_128_encrypt(empty_buffer, 0, aad, sizeof(aad), key, iv, ciphertext, tag);
  BOOST_CHECK(size == 0);
  BOOST_CHECK_EQUAL_COLLECTIONS(tag, tag + 16, expected_tag, expected_tag + sizeof(expected_tag));

  uint8_t decrypted[256] = {0};
  size = aes_gcm_128_decrypt(ciphertext, size, aad, sizeof(aad), tag, key, iv, decrypted);
  BOOST_CHECK(size == 0);
}

BOOST_AUTO_TEST_CASE(AesGcm3)
{
  // Test case from NIST Cryptographic Algorithm Validation Program
  // https://csrc.nist.gov/Projects/cryptographic-algorithm-validation-program/CAVP-TESTING-BLOCK-CIPHER-MODES
  // Count = 0
  // Key = bc22f3f05cc40db9311e4192966fee92
  // IV = 134988e662343c06d3ab83db
  // CT = 4c0168ab95d3a10ef25e5924108389365c67d97778995892d9fd46897384af61fc559212b3267e90fe4df7bfd1fbed46f4b9ee
  // AAD = 10087e6ed81049b509c31d12fee88c64
  // Tag = 771357958a316f166bd0dacc98ea801a
  // PT = 337c1bc992386cf0f957617fe4d5ec1218ae1cc40369305518eb177e9b15c1646b142ff71237efaa58790080cd82e8848b295c
  const uint8_t key[] = {0xbc, 0x22, 0xf3, 0xf0, 0x5c, 0xc4, 0x0d, 0xb9,
                         0x31, 0x1e, 0x41, 0x92, 0x96, 0x6f, 0xee, 0x92};
  const uint8_t iv[] = {0x13, 0x49, 0x88, 0xe6, 0x62, 0x34,
                        0x3c, 0x06, 0xd3, 0xab, 0x83, 0xdb};
  const uint8_t aad[] = {0x10, 0x08, 0x7e, 0x6e, 0xd8, 0x10, 0x49, 0xb5,
                         0x09, 0xc3, 0x1d, 0x12, 0xfe, 0xe8, 0x8c, 0x64};
  const uint8_t expected_ciphertext[] = {
      0x4c, 0x01, 0x68, 0xab, 0x95, 0xd3, 0xa1, 0x0e, 0xf2, 0x5e, 0x59,
      0x24, 0x10, 0x83, 0x89, 0x36, 0x5c, 0x67, 0xd9, 0x77, 0x78, 0x99,
      0x58, 0x92, 0xd9, 0xfd, 0x46, 0x89, 0x73, 0x84, 0xaf, 0x61, 0xfc,
      0x55, 0x92, 0x12, 0xb3, 0x26, 0x7e, 0x90, 0xfe, 0x4d, 0xf7, 0xbf,
      0xd1, 0xfb, 0xed, 0x46, 0xf4, 0xb9, 0xee};
  const uint8_t expected_tag[] = {0x77, 0x13, 0x57, 0x95, 0x8a, 0x31,
                                  0x6f, 0x16, 0x6b, 0xd0, 0xda, 0xcc,
                                  0x98, 0xea, 0x80, 0x1a};
  const uint8_t plaintext[] = {
      0x33, 0x7c, 0x1b, 0xc9, 0x92, 0x38, 0x6c, 0xf0, 0xf9, 0x57, 0x61,
      0x7f, 0xe4, 0xd5, 0xec, 0x12, 0x18, 0xae, 0x1c, 0xc4, 0x03, 0x69,
      0x30, 0x55, 0x18, 0xeb, 0x17, 0x7e, 0x9b, 0x15, 0xc1, 0x64, 0x6b,
      0x14, 0x2f, 0xf7, 0x12, 0x37, 0xef, 0xaa, 0x58, 0x79, 0x00, 0x80,
      0xcd, 0x82, 0xe8, 0x84, 0x8b, 0x29, 0x5c};

  uint8_t ciphertext[256] = {0};
  uint8_t tag[16] = {0};
  int size = aes_gcm_128_encrypt(plaintext, sizeof(plaintext), aad, sizeof(aad), key, iv, ciphertext, tag);
  BOOST_CHECK_EQUAL_COLLECTIONS(ciphertext, ciphertext + size,
                                expected_ciphertext, expected_ciphertext + sizeof(expected_ciphertext));
  BOOST_CHECK_EQUAL_COLLECTIONS(tag, tag + 16, expected_tag, expected_tag + sizeof(expected_tag));

  uint8_t decrypted[256] = {0};
  size = aes_gcm_128_decrypt(ciphertext, size, aad, sizeof(aad), tag, key, iv, decrypted);
  BOOST_CHECK_EQUAL_COLLECTIONS(decrypted, decrypted + size,
                                plaintext, plaintext + sizeof(plaintext));
}

BOOST_AUTO_TEST_CASE(BlockEncodingDecoding)
{
  const uint8_t key[] = {0xbc, 0x22, 0xf3, 0xf0, 0x5c, 0xc4, 0x0d, 0xb9,
                         0x31, 0x1e, 0x41, 0x92, 0x96, 0x6f, 0xee, 0x92};
  const std::string plaintext = "alongstringalongstringalongstringalongstringalongstringalongstringalongstringalongstring";
  const std::string associatedData = "test";
  auto block = encodeBlockWithAesGcm128(ndn::tlv::Content, key, (uint8_t*)plaintext.c_str(), plaintext.size(),
                                        (uint8_t*)associatedData.c_str(), associatedData.size());
  auto decoded = decodeBlockWithAesGcm128(block, key, (uint8_t*)associatedData.c_str(), associatedData.size());
  BOOST_CHECK_EQUAL(plaintext, std::string((char*)decoded.get<uint8_t>(), decoded.size()));
}

BOOST_AUTO_TEST_SUITE_END()

} // namespace tests
} // namespace ndncert
} // namespace ndn
