/*
 * Copyright (C) 2020-2021 Aloysius Indrayanto
 *
 * This file is part of the eCxx library, see LICENSE file for the license details.
 */

/*
 * This is a special header file for compatibility with the Arduino library part
 */


#ifndef ECXX_PLATFORM_NODEMCU_LIBACOMPAT_UPDATER_SIGNING_H
#define ECXX_PLATFORM_NODEMCU_LIBACOMPAT_UPDATER_SIGNING_H


//
// Include the eCxx header file
//
extern "C++" {
    #include "../Updater.h"
}


//
// Define the Arduino signing macro as needed
//
#ifdef ECXX_NODEMCU_BINARY_SIGNING_VERIFICATION
    #define ARDUINO_SIGNING 1
#else
    #define ARDUINO_SIGNING 0
#endif


//
// Define the public key as needed
//
#ifdef ECXX_NODEMCU_BINARY_SIGNING_VERIFICATION
    /* There are two methods to define the signing public key:
     *
     *     1. Execute "make xpk" to produce "build/_public_key.h". The resulting array
     *        ("signing_pubkey") will be inside the file. If you choose to use this method,
     *        please add 0x00 at the end of the array because the Python script forgot
     *        to add the null terminator.
     *
     *     2. Copy the contents of "keys/public.key" and paste it below. If you choose to
     *        use this method, please add '\n' at the end of every lines copied from the
     *        file. Do not format (beautify) the string using whitespace! It would also be
     *        possible to use C++11 raw string literal such as: R"EOF(...)EOF".
     *
     * Please refer to "keys/README" for more information.
     *
     * NOTE : The macro "ECXX_NODEMCU_BINARY_SIGNING_VERIFICATION" in "../Updater.h" is used
     *        to control whether binary signing verification will be enabled for OTA programming.
     *
     * NOTE : If you updated this file, simply execute "make xpk" to delete some generated
     *        files so that this header will be recompiled (even you do not need to use the
     *        array from the generated file "build/_public_key.h").
     */
    static const char PROGMEM signing_pubkey[] = "\
-----BEGIN PUBLIC KEY-----\n\
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmL4mATW2n645jWJWl0i+\n\
1cuHFHqpUaKdPwHCvDzeQEAZJTezeHT8lM+9cnWVMmli3drVDN6ExvnUpnEiMR7q\n\
mYLcINvTH60li1TggDNUIRu44YFRsololX6i3ADYvT35E/QMK6dugfNnbb8PdF73\n\
VNdvIQ5nmML/MYPfIGV5+jKKQpThWfAfFvejnb+RHaHjfuARRF0GMvTbS3JPFrJP\n\
aLu4TXf/kNqGJJGUcmIqG9DHr/YGtkL4zn9bcSt9Isz9tKwwFHc+X+tfOBYoXdYF\n\
Ve+yuJ6Zsmw7O9WjGlRjlyb2ukAhRMTUq4tzDZyZFtKZcZn4vgYmiRZrJVlFVqMd\n\
+QIDAQAB\n\
-----END PUBLIC KEY-----\n\
";
#endif


#endif
