/* -*- 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.
 */

#ifndef NDNCERT_DETAIL_CRYPTO_HELPERS_HPP
#define NDNCERT_DETAIL_CRYPTO_HELPERS_HPP

#include "detail/ndncert-common.hpp"
#include <openssl/evp.h>

namespace ndn {
namespace ndncert {

/**
 * @brief State for ECDH.
 *
 * The ECDH is based on prime256v1.
 */
class ECDHState : noncopyable
{
public:
  ECDHState();
  ~ECDHState();

  /**
   * @brief Derive ECDH secret from peer's EC public key and self's private key.
   *
   * @param peerkey Peer's EC public key in the uncompressed octet string format.
   *                See details in https://www.openssl.org/docs/man1.1.1/man3/EC_POINT_point2oct.html.
   * @return const std::vector<uint8_t>& the derived secret.
   */
  const std::vector<uint8_t>&
  deriveSecret(const std::vector<uint8_t>& peerkey);

  /**
   * @brief Get the Self Pub Key object
   *
   * @return const std::vector<uint8_t>& the Self public key in the uncompressed oct string format.
   *         See details in https://www.openssl.org/docs/man1.1.1/man3/EC_POINT_point2oct.html.
   */
  const std::vector<uint8_t>&
  getSelfPubKey();

private:
  EVP_PKEY* m_privkey = nullptr;
  std::vector<uint8_t> m_pubKey;
  std::vector<uint8_t> m_secret;
};

/**
 * @brief HMAC based key derivation function (HKDF).
 *
 * @param secret The input to the HKDF.
 * @param secretLen The length of the secret.
 * @param salt The salt used in HKDF.
 * @param saltLen The length of the salt.
 * @param output The output of the HKDF.
 * @param outputLen The length of expected output.
 * @param info The additional information used in HKDF.
 * @param infoLen The length of the additional information.
 * @return size_t The length of the derived key if successful.
 */
size_t
hkdf(const uint8_t* secret, size_t secretLen,
     const uint8_t* salt, size_t saltLen,
     uint8_t* output, size_t outputLen,
     const uint8_t* info = nullptr, size_t infoLen = 0);

/**
 * @brief HMAC based on SHA-256.
 *
 * @param data The intput array to hmac.
 * @param dataLen The length of the input array.
 * @param key The HMAC key.
 * @param keyLen The length of the HMAC key.
 * @param result The result of the HMAC. Enough memory (32 Bytes) must be allocated beforehands.
 * @throw runtime_error when an error occurred in the underlying HMAC.
 */
void
hmacSha256(const uint8_t* data, size_t dataLen,
           const uint8_t* key, size_t keyLen,
           uint8_t* result);

/**
 * @brief Authenticated GCM 128 Encryption with associated data.
 *
 * @param plaintext The plaintext.
 * @param plaintextLen The size of plaintext.
 * @param associated The associated authentication data.
 * @param associatedLen The size of associated authentication data.
 * @param key 16 bytes AES key.
 * @param iv 12 bytes IV.
 * @param ciphertext The output and enough memory must be allocated beforehands.
 * @param tag 16 bytes tag.
 * @return size_t The size of ciphertext.
 * @throw runtime_error When there is an error in the process of encryption.
 */
size_t
aesGcm128Encrypt(const uint8_t* plaintext, size_t plaintextLen, const uint8_t* associated, size_t associatedLen,
                 const uint8_t* key, const uint8_t* iv, uint8_t* ciphertext, uint8_t* tag);

/**
 * @brief Authenticated GCM 128 Decryption with associated data.
 *
 * @param ciphertext The ciphertext.
 * @param ciphertextLen The size of ciphertext.
 * @param associated The associated authentication data.
 * @param associatedLen The size of associated authentication data.
 * @param tag 16 bytes tag.
 * @param key 16 bytes AES key.
 * @param iv 12 bytes IV.
 * @param plaintext The output and enough memory must be allocated beforehands.
 * @return size_t The size of plaintext.
 * @throw runtime_error When there is an error in the process of decryption.
 */
size_t
aesGcm128Decrypt(const uint8_t* ciphertext, size_t ciphertextLen, const uint8_t* associated, size_t associatedLen,
                 const uint8_t* tag, const uint8_t* key, const uint8_t* iv, uint8_t* plaintext);

/**
 * @brief Encode the payload into TLV block with Authenticated GCM 128 Encryption.
 *
 * The TLV spec: https://github.com/named-data/ndncert/wiki/NDNCERT-Protocol-0.3#242-aes-gcm-encryption.
 *
 * @param tlv_type The TLV TYPE of the encoded block, either ApplicationParameters or Content.
 * @param key The AES key used for encryption.
 * @param payload The plaintext payload.
 * @param payloadSize The size of the plaintext payload.
 * @param associatedData The associated data used for authentication.
 * @param associatedDataSize The size of associated data.
 * @param encryptionIv The IV used by the last AES encryption and is needed by subsequent invocations of this function
 *                     with the same @p key.
 * @return Block The TLV block with @p tlv_type TLV TYPE.
 */
Block
encodeBlockWithAesGcm128(uint32_t tlvType, const uint8_t* key,
                         const uint8_t* payload, size_t payloadSize,
                         const uint8_t* associatedData, size_t associatedDataSize,
                         std::vector<uint8_t>& encryptionIv);

/**
 * @brief Decode the payload from TLV block with Authenticated GCM 128 Encryption.
 *
 * The TLV spec: https://github.com/named-data/ndncert/wiki/NDNCERT-Protocol-0.3#242-aes-gcm-encryption.
 *
 * @param block The TLV block in the format of NDNCERT protocol.
 * @param key The AES key used for encryption.
 * @param associatedData The associated data used for authentication.
 * @param associatedDataSize The size of associated data.
 * @param decryptionIv The IV observed in the last AES decryption and is needed by subsequent
 *                     invocations of this function with the same @p key.
 * @return Buffer The plaintext buffer.
 */
Buffer
decodeBlockWithAesGcm128(const Block& block, const uint8_t* key,
                         const uint8_t* associatedData, size_t associatedDataSize,
                         std::vector<uint8_t>& decryptionIv, const std::vector<uint8_t>& encryptionIv);

} // namespace ndncert
} // namespace ndn

#endif // NDNCERT_DETAIL_CRYPTO_HELPERS_HPP
