123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969 |
- /**
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form, except as embedded into a Nordic
- * Semiconductor ASA integrated circuit in a product or a software update for
- * such product, must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * 4. This software, with or without modification, must only be used with a
- * Nordic Semiconductor ASA integrated circuit.
- *
- * 5. Any software provided in binary form under this license must not be reverse
- * engineered, decompiled, modified and/or disassembled.
- *
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
- #ifndef NRF_CRYPTO_ECC_H__
- #define NRF_CRYPTO_ECC_H__
- /** @addtogroup nrf_crypto
- * @{
- * @addtogroup nrf_crypto_ecc Elliptic Curve Cryptography Key Management
- * @{
- * @brief Provides elliptic curve cryptography API for public and private key management.
- *
- * @addtogroup nrf_crypto_ecc_secp160r1 Definitions specific to secp160r1 (NIST 160-bit)
- * @addtogroup nrf_crypto_ecc_secp160r2 Definitions specific to secp160r2 (NIST 160-bit)
- * @addtogroup nrf_crypto_ecc_secp192r1 Definitions specific to secp192r1 (NIST 192-bit)
- * @addtogroup nrf_crypto_ecc_secp224r1 Definitions specific to secp224r1 (NIST 224-bit)
- * @addtogroup nrf_crypto_ecc_secp256r1 Definitions specific to secp256r1 (NIST 256-bit)
- * @addtogroup nrf_crypto_ecc_secp384r1 Definitions specific to secp384r1 (NIST 384-bit)
- * @addtogroup nrf_crypto_ecc_secp521r1 Definitions specific to secp521r1 (NIST 521-bit)
- * @addtogroup nrf_crypto_ecc_secp160k1 Definitions specific to secp160k1 (Koblitz 160-bit)
- * @addtogroup nrf_crypto_ecc_secp192k1 Definitions specific to secp192k1 (Koblitz 192-bit)
- * @addtogroup nrf_crypto_ecc_secp224k1 Definitions specific to secp224k1 (Koblitz 224-bit)
- * @addtogroup nrf_crypto_ecc_secp256k1 Definitions specific to secp256k1 (Koblitz 256-bit)
- * @addtogroup nrf_crypto_ecc_bp256r1 Definitions specific to bp256r1 (Brainpool 256-bit)
- * @addtogroup nrf_crypto_ecc_bp384r1 Definitions specific to bp384r1 (Brainpool 384-bit)
- * @addtogroup nrf_crypto_ecc_bp512r1 Definitions specific to bp512r1 (Brainpool 512-bit)
- * @addtogroup nrf_crypto_ecc_curve25519 Definitions specific to Curve25519
- * @addtogroup nrf_crypto_ecc_ed25519 Definitions specific to Ed25519
- */
- #include <stdint.h>
- #include <stddef.h>
- #include "nrf_crypto_error.h"
- #include "nrf_crypto_ecc_shared.h"
- #include "nrf_crypto_ecc_backend.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #if defined(__SDK_DOXYGEN__)
- #define NRF_CRYPTO_ECC_SECP160R1_ENABLED 1 /**< @brief Defined as 1 if secp160r1 (NIST 160-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp160r1 */
- #define NRF_CRYPTO_ECC_SECP160R2_ENABLED 1 /**< @brief Defined as 1 if secp160r2 (NIST 160-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp160r2 */
- #define NRF_CRYPTO_ECC_SECP192R1_ENABLED 1 /**< @brief Defined as 1 if secp192r1 (NIST 192-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp192r1 */
- #define NRF_CRYPTO_ECC_SECP224R1_ENABLED 1 /**< @brief Defined as 1 if secp224r1 (NIST 224-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp224r1 */
- #define NRF_CRYPTO_ECC_SECP256R1_ENABLED 1 /**< @brief Defined as 1 if secp256r1 (NIST 256-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp256r1 */
- #define NRF_CRYPTO_ECC_SECP384R1_ENABLED 1 /**< @brief Defined as 1 if secp384r1 (NIST 384-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp384r1 */
- #define NRF_CRYPTO_ECC_SECP521R1_ENABLED 1 /**< @brief Defined as 1 if secp521r1 (NIST 521-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp521r1 */
- #define NRF_CRYPTO_ECC_SECP160K1_ENABLED 1 /**< @brief Defined as 1 if secp160k1 (Koblitz 160-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp160k1 */
- #define NRF_CRYPTO_ECC_SECP192K1_ENABLED 1 /**< @brief Defined as 1 if secp192k1 (Koblitz 192-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp192k1 */
- #define NRF_CRYPTO_ECC_SECP224K1_ENABLED 1 /**< @brief Defined as 1 if secp224k1 (Koblitz 224-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp224k1 */
- #define NRF_CRYPTO_ECC_SECP256K1_ENABLED 1 /**< @brief Defined as 1 if secp256k1 (Koblitz 256-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_secp256k1 */
- #define NRF_CRYPTO_ECC_BP256R1_ENABLED 1 /**< @brief Defined as 1 if bp256r1 (Brainpool 256-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_bp256r1 */
- #define NRF_CRYPTO_ECC_BP384R1_ENABLED 1 /**< @brief Defined as 1 if bp384r1 (Brainpool 384-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_bp384r1 */
- #define NRF_CRYPTO_ECC_BP512R1_ENABLED 1 /**< @brief Defined as 1 if bp512r1 (Brainpool 512-bit) is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_bp512r1 */
- #define NRF_CRYPTO_ECC_CURVE25519_ENABLED 1 /**< @brief Defined as 1 if Curve25519 is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_curve25519 */
- #define NRF_CRYPTO_ECC_ED25519_ENABLED 1 /**< @brief Defined as 1 if Ed25519 is enabled in any of the backends and it is usable in the API, 0 otherwise. @ingroup nrf_crypto_ecc_ed25519 */
- #endif
- #define NRF_CRYPTO_ECC_SECP160R1_RAW_PRIVATE_KEY_SIZE (160 / 8) /**< @brief Raw private key size for secp160r1 (NIST 160-bit). @ingroup nrf_crypto_ecc_secp160r1 */
- #define NRF_CRYPTO_ECC_SECP160R2_RAW_PRIVATE_KEY_SIZE (160 / 8) /**< @brief Raw private key size for secp160r2 (NIST 160-bit). @ingroup nrf_crypto_ecc_secp160r2 */
- #define NRF_CRYPTO_ECC_SECP192R1_RAW_PRIVATE_KEY_SIZE (192 / 8) /**< @brief Raw private key size for secp192r1 (NIST 192-bit). @ingroup nrf_crypto_ecc_secp192r1 */
- #define NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE (224 / 8) /**< @brief Raw private key size for secp224r1 (NIST 224-bit). @ingroup nrf_crypto_ecc_secp224r1 */
- #define NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for secp256r1 (NIST 256-bit). @ingroup nrf_crypto_ecc_secp256r1 */
- #define NRF_CRYPTO_ECC_SECP384R1_RAW_PRIVATE_KEY_SIZE (384 / 8) /**< @brief Raw private key size for secp384r1 (NIST 384-bit). @ingroup nrf_crypto_ecc_secp384r1 */
- #define NRF_CRYPTO_ECC_SECP521R1_RAW_PRIVATE_KEY_SIZE (528 / 8) /**< @brief Raw private key size for secp521r1 (NIST 521-bit). @ingroup nrf_crypto_ecc_secp521r1 */
- #define NRF_CRYPTO_ECC_SECP160K1_RAW_PRIVATE_KEY_SIZE (160 / 8) /**< @brief Raw private key size for secp160k1 (Koblitz 160-bit). @ingroup nrf_crypto_ecc_secp160k1 */
- #define NRF_CRYPTO_ECC_SECP192K1_RAW_PRIVATE_KEY_SIZE (192 / 8) /**< @brief Raw private key size for secp192k1 (Koblitz 192-bit). @ingroup nrf_crypto_ecc_secp192k1 */
- #define NRF_CRYPTO_ECC_SECP224K1_RAW_PRIVATE_KEY_SIZE (224 / 8) /**< @brief Raw private key size for secp224k1 (Koblitz 224-bit). @ingroup nrf_crypto_ecc_secp224k1 */
- #define NRF_CRYPTO_ECC_SECP256K1_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for secp256k1 (Koblitz 256-bit). @ingroup nrf_crypto_ecc_secp256k1 */
- #define NRF_CRYPTO_ECC_BP256R1_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for bp256r1 (Brainpool 256-bit). @ingroup nrf_crypto_ecc_bp256r1 */
- #define NRF_CRYPTO_ECC_BP384R1_RAW_PRIVATE_KEY_SIZE (384 / 8) /**< @brief Raw private key size for bp384r1 (Brainpool 384-bit). @ingroup nrf_crypto_ecc_bp384r1 */
- #define NRF_CRYPTO_ECC_BP512R1_RAW_PRIVATE_KEY_SIZE (512 / 8) /**< @brief Raw private key size for bp512r1 (Brainpool 512-bit). @ingroup nrf_crypto_ecc_bp512r1 */
- #define NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for Curve25519. @ingroup nrf_crypto_ecc_curve25519 */
- #define NRF_CRYPTO_ECC_ED25519_RAW_PRIVATE_KEY_SIZE (256 / 8) /**< @brief Raw private key size for Ed25519. @ingroup nrf_crypto_ecc_ed25519 */
- #define NRF_CRYPTO_ECC_SECP160R1_RAW_PUBLIC_KEY_SIZE (2 * 160 / 8) /**< @brief Raw public key size for curve secp160r1 (NIST 160-bit). @ingroup nrf_crypto_ecc_secp160r1 */
- #define NRF_CRYPTO_ECC_SECP160R2_RAW_PUBLIC_KEY_SIZE (2 * 160 / 8) /**< @brief Raw public key size for curve secp160r2 (NIST 160-bit). @ingroup nrf_crypto_ecc_secp160r2 */
- #define NRF_CRYPTO_ECC_SECP192R1_RAW_PUBLIC_KEY_SIZE (2 * 192 / 8) /**< @brief Raw public key size for curve secp192r1 (NIST 192-bit). @ingroup nrf_crypto_ecc_secp192r1 */
- #define NRF_CRYPTO_ECC_SECP224R1_RAW_PUBLIC_KEY_SIZE (2 * 224 / 8) /**< @brief Raw public key size for curve secp224r1 (NIST 224-bit). @ingroup nrf_crypto_ecc_secp224r1 */
- #define NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE (2 * 256 / 8) /**< @brief Raw public key size for curve secp256r1 (NIST 256-bit). @ingroup nrf_crypto_ecc_secp256r1 */
- #define NRF_CRYPTO_ECC_SECP384R1_RAW_PUBLIC_KEY_SIZE (2 * 384 / 8) /**< @brief Raw public key size for curve secp384r1 (NIST 384-bit). @ingroup nrf_crypto_ecc_secp384r1 */
- #define NRF_CRYPTO_ECC_SECP521R1_RAW_PUBLIC_KEY_SIZE (2 * 528 / 8) /**< @brief Raw public key size for curve secp521r1 (NIST 521-bit). @ingroup nrf_crypto_ecc_secp521r1 */
- #define NRF_CRYPTO_ECC_SECP160K1_RAW_PUBLIC_KEY_SIZE (2 * 160 / 8) /**< @brief Raw public key size for curve secp160k1 (Koblitz 160-bit). @ingroup nrf_crypto_ecc_secp160k1 */
- #define NRF_CRYPTO_ECC_SECP192K1_RAW_PUBLIC_KEY_SIZE (2 * 192 / 8) /**< @brief Raw public key size for curve secp192k1 (Koblitz 192-bit). @ingroup nrf_crypto_ecc_secp192k1 */
- #define NRF_CRYPTO_ECC_SECP224K1_RAW_PUBLIC_KEY_SIZE (2 * 224 / 8) /**< @brief Raw public key size for curve secp224k1 (Koblitz 224-bit). @ingroup nrf_crypto_ecc_secp224k1 */
- #define NRF_CRYPTO_ECC_SECP256K1_RAW_PUBLIC_KEY_SIZE (2 * 256 / 8) /**< @brief Raw public key size for curve secp256k1 (Koblitz 256-bit). @ingroup nrf_crypto_ecc_secp256k1 */
- #define NRF_CRYPTO_ECC_BP256R1_RAW_PUBLIC_KEY_SIZE (2 * 256 / 8) /**< @brief Raw public key size for curve bp256r1 (Brainpool 256-bit). @ingroup nrf_crypto_ecc_bp256r1 */
- #define NRF_CRYPTO_ECC_BP384R1_RAW_PUBLIC_KEY_SIZE (2 * 384 / 8) /**< @brief Raw public key size for curve bp384r1 (Brainpool 384-bit). @ingroup nrf_crypto_ecc_bp384r1 */
- #define NRF_CRYPTO_ECC_BP512R1_RAW_PUBLIC_KEY_SIZE (2 * 512 / 8) /**< @brief Raw public key size for curve bp512r1 (Brainpool 512-bit). @ingroup nrf_crypto_ecc_bp512r1 */
- #define NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE (256 / 8) /**< @brief Raw public key size for curve Curve25519. @ingroup nrf_crypto_ecc_curve25519 */
- #define NRF_CRYPTO_ECC_ED25519_RAW_PUBLIC_KEY_SIZE (256 / 8) /**< @brief Raw public key size for curve Ed25519. @ingroup nrf_crypto_ecc_ed25519 */
- #define NRF_CRYPTO_ECC_RAW_PRIVATE_KEY_MAX_SIZE NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE /**< @brief Maximum size of a raw private key for all enabled curves. */
- #define NRF_CRYPTO_ECC_RAW_PUBLIC_KEY_MAX_SIZE NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE /**< @brief Maximum size of a raw public key for all enabled curves. */
- /** @brief Defines type of ECC curve.
- */
- typedef enum
- {
- #if NRF_CRYPTO_ECC_SECP160R1_ENABLED
- NRF_CRYPTO_ECC_SECP160R1_CURVE_TYPE, /**< secp160r1 (NIST 160-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP160R2_ENABLED
- NRF_CRYPTO_ECC_SECP160R2_CURVE_TYPE, /**< secp160r2 (NIST 160-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP192R1_ENABLED
- NRF_CRYPTO_ECC_SECP192R1_CURVE_TYPE, /**< secp192r1 (NIST 192-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP224R1_ENABLED
- NRF_CRYPTO_ECC_SECP224R1_CURVE_TYPE, /**< secp224r1 (NIST 224-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP256R1_ENABLED
- NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, /**< secp256r1 (NIST 256-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP384R1_ENABLED
- NRF_CRYPTO_ECC_SECP384R1_CURVE_TYPE, /**< secp384r1 (NIST 384-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP521R1_ENABLED
- NRF_CRYPTO_ECC_SECP521R1_CURVE_TYPE, /**< secp521r1 (NIST 521-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP160K1_ENABLED
- NRF_CRYPTO_ECC_SECP160K1_CURVE_TYPE, /**< secp160k1 (Koblitz 160-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP192K1_ENABLED
- NRF_CRYPTO_ECC_SECP192K1_CURVE_TYPE, /**< secp192k1 (Koblitz 192-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP224K1_ENABLED
- NRF_CRYPTO_ECC_SECP224K1_CURVE_TYPE, /**< secp224k1 (Koblitz 224-bit) */
- #endif
- #if NRF_CRYPTO_ECC_SECP256K1_ENABLED
- NRF_CRYPTO_ECC_SECP256K1_CURVE_TYPE, /**< secp256k1 (Koblitz 256-bit) */
- #endif
- #if NRF_CRYPTO_ECC_BP256R1_ENABLED
- NRF_CRYPTO_ECC_BP256R1_CURVE_TYPE, /**< bp256r1 (Brainpool 256-bit) */
- #endif
- #if NRF_CRYPTO_ECC_BP384R1_ENABLED
- NRF_CRYPTO_ECC_BP384R1_CURVE_TYPE, /**< bp384r1 (Brainpool 384-bit) */
- #endif
- #if NRF_CRYPTO_ECC_BP512R1_ENABLED
- NRF_CRYPTO_ECC_BP512R1_CURVE_TYPE, /**< bp512r1 (Brainpool 512-bit) */
- #endif
- #if NRF_CRYPTO_ECC_CURVE25519_ENABLED
- NRF_CRYPTO_ECC_CURVE25519_CURVE_TYPE, /**< Curve25519 */
- #endif
- #if NRF_CRYPTO_ECC_ED25519_ENABLED
- NRF_CRYPTO_ECC_ED25519_CURVE_TYPE, /**< Ed25519 */
- #endif
- #if !NRF_CRYPTO_ECC_SECP160R1_ENABLED
- NRF_CRYPTO_ECC_SECP160R1_CURVE_TYPE, /**< secp160r1 (NIST 160-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP160R2_ENABLED
- NRF_CRYPTO_ECC_SECP160R2_CURVE_TYPE, /**< secp160r2 (NIST 160-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP192R1_ENABLED
- NRF_CRYPTO_ECC_SECP192R1_CURVE_TYPE, /**< secp192r1 (NIST 192-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP224R1_ENABLED
- NRF_CRYPTO_ECC_SECP224R1_CURVE_TYPE, /**< secp224r1 (NIST 224-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP256R1_ENABLED
- NRF_CRYPTO_ECC_SECP256R1_CURVE_TYPE, /**< secp256r1 (NIST 256-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP384R1_ENABLED
- NRF_CRYPTO_ECC_SECP384R1_CURVE_TYPE, /**< secp384r1 (NIST 384-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP521R1_ENABLED
- NRF_CRYPTO_ECC_SECP521R1_CURVE_TYPE, /**< secp521r1 (NIST 521-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP160K1_ENABLED
- NRF_CRYPTO_ECC_SECP160K1_CURVE_TYPE, /**< secp160k1 (Koblitz 160-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP192K1_ENABLED
- NRF_CRYPTO_ECC_SECP192K1_CURVE_TYPE, /**< secp192k1 (Koblitz 192-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP224K1_ENABLED
- NRF_CRYPTO_ECC_SECP224K1_CURVE_TYPE, /**< secp224k1 (Koblitz 224-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_SECP256K1_ENABLED
- NRF_CRYPTO_ECC_SECP256K1_CURVE_TYPE, /**< secp256k1 (Koblitz 256-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_BP256R1_ENABLED
- NRF_CRYPTO_ECC_BP256R1_CURVE_TYPE, /**< bp256r1 (Brainpool 256-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_BP384R1_ENABLED
- NRF_CRYPTO_ECC_BP384R1_CURVE_TYPE, /**< bp384r1 (Brainpool 384-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_BP512R1_ENABLED
- NRF_CRYPTO_ECC_BP512R1_CURVE_TYPE, /**< bp512r1 (Brainpool 512-bit) */
- #endif
- #if !NRF_CRYPTO_ECC_CURVE25519_ENABLED
- NRF_CRYPTO_ECC_CURVE25519_CURVE_TYPE, /**< Curve25519 */
- #endif
- #if !NRF_CRYPTO_ECC_ED25519_ENABLED
- NRF_CRYPTO_ECC_ED25519_CURVE_TYPE, /**< Ed25519 */
- #endif
- } nrf_crypto_ecc_curve_type_t;
- /** @brief Structure holding information on a specific curve.
- *
- * @note This structure cannot be used to create a new variable. Only the variables defined by this
- * library can be used, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info.
- */
- typedef struct nrf_crypto_ecc_curve_info_s
- {
- uint16_t public_key_size; /**< @brief Size of a structure holding internal public key. */
- uint16_t private_key_size; /**< @brief Size of a structure holding internal private key. */
- nrf_crypto_ecc_curve_type_t curve_type; /**< @brief Type of the curve. */
- uint8_t raw_private_key_size; /**< @brief Size of a buffer containing raw private key. */
- uint8_t raw_public_key_size; /**< @brief Size of a buffer containing raw public key. */
- void * p_backend_data; /**< @brief Field to hold backend specific internal data. */
- } nrf_crypto_ecc_curve_info_t;
- /** @addtogroup nrf_crypto_ecc_secp160r1
- * @{ */
- typedef nrf_crypto_backend_secp160r1_key_pair_generate_context_t
- nrf_crypto_ecc_secp160r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp160r1 (NIST 160-bit). */
- typedef nrf_crypto_backend_secp160r1_public_key_calculate_context_t
- nrf_crypto_ecc_secp160r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp160r1 (NIST 160-bit). */
- typedef nrf_crypto_backend_secp160r1_private_key_t
- nrf_crypto_ecc_secp160r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp160r1 (NIST 160-bit) */
- typedef nrf_crypto_backend_secp160r1_public_key_t
- nrf_crypto_ecc_secp160r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp160r1 (NIST 160-bit) */
- typedef uint8_t nrf_crypto_ecc_secp160r1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP160R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp160r1 (NIST 160-bit) */
- typedef uint8_t nrf_crypto_ecc_secp160r1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP160R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp160r1 (NIST 160-bit) */
- /** @brief Variable containing information on secp160r1 (NIST 160-bit).
- *
- * It can be used as a parameter for the functions creating secp160r1 (NIST 160-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp160r1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp160r2
- * @{ */
- typedef nrf_crypto_backend_secp160r2_key_pair_generate_context_t
- nrf_crypto_ecc_secp160r2_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp160r2 (NIST 160-bit). */
- typedef nrf_crypto_backend_secp160r2_public_key_calculate_context_t
- nrf_crypto_ecc_secp160r2_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp160r2 (NIST 160-bit). */
- typedef nrf_crypto_backend_secp160r2_private_key_t
- nrf_crypto_ecc_secp160r2_private_key_t; /**< @brief Structure holding internal representation of a private key for secp160r2 (NIST 160-bit) */
- typedef nrf_crypto_backend_secp160r2_public_key_t
- nrf_crypto_ecc_secp160r2_public_key_t; /**< @brief Structure holding internal representation of a public key for secp160r2 (NIST 160-bit) */
- typedef uint8_t nrf_crypto_ecc_secp160r2_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP160R2_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp160r2 (NIST 160-bit) */
- typedef uint8_t nrf_crypto_ecc_secp160r2_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP160R2_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp160r2 (NIST 160-bit) */
- /** @brief Variable containing information on secp160r2 (NIST 160-bit).
- *
- * It can be used as a parameter for the functions creating secp160r2 (NIST 160-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp160r2_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp192r1
- * @{ */
- typedef nrf_crypto_backend_secp192r1_key_pair_generate_context_t
- nrf_crypto_ecc_secp192r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp192r1 (NIST 192-bit). */
- typedef nrf_crypto_backend_secp192r1_public_key_calculate_context_t
- nrf_crypto_ecc_secp192r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp192r1 (NIST 192-bit). */
- typedef nrf_crypto_backend_secp192r1_private_key_t
- nrf_crypto_ecc_secp192r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp192r1 (NIST 192-bit) */
- typedef nrf_crypto_backend_secp192r1_public_key_t
- nrf_crypto_ecc_secp192r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp192r1 (NIST 192-bit) */
- typedef uint8_t nrf_crypto_ecc_secp192r1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP192R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp192r1 (NIST 192-bit) */
- typedef uint8_t nrf_crypto_ecc_secp192r1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP192R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp192r1 (NIST 192-bit) */
- /** @brief Variable containing information on secp192r1 (NIST 192-bit).
- *
- * It can be used as a parameter for the functions creating secp192r1 (NIST 192-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp192r1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp224r1
- * @{ */
- typedef nrf_crypto_backend_secp224r1_key_pair_generate_context_t
- nrf_crypto_ecc_secp224r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp224r1 (NIST 224-bit). */
- typedef nrf_crypto_backend_secp224r1_public_key_calculate_context_t
- nrf_crypto_ecc_secp224r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp224r1 (NIST 224-bit). */
- typedef nrf_crypto_backend_secp224r1_private_key_t
- nrf_crypto_ecc_secp224r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp224r1 (NIST 224-bit) */
- typedef nrf_crypto_backend_secp224r1_public_key_t
- nrf_crypto_ecc_secp224r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp224r1 (NIST 224-bit) */
- typedef uint8_t nrf_crypto_ecc_secp224r1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP224R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp224r1 (NIST 224-bit) */
- typedef uint8_t nrf_crypto_ecc_secp224r1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP224R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp224r1 (NIST 224-bit) */
- /** @brief Variable containing information on secp224r1 (NIST 224-bit).
- *
- * It can be used as a parameter for the functions creating secp224r1 (NIST 224-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp224r1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp256r1
- * @{ */
- typedef nrf_crypto_backend_secp256r1_key_pair_generate_context_t
- nrf_crypto_ecc_secp256r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp256r1 (NIST 256-bit). */
- typedef nrf_crypto_backend_secp256r1_public_key_calculate_context_t
- nrf_crypto_ecc_secp256r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp256r1 (NIST 256-bit). */
- typedef nrf_crypto_backend_secp256r1_private_key_t
- nrf_crypto_ecc_secp256r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp256r1 (NIST 256-bit) */
- typedef nrf_crypto_backend_secp256r1_public_key_t
- nrf_crypto_ecc_secp256r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp256r1 (NIST 256-bit) */
- typedef uint8_t nrf_crypto_ecc_secp256r1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp256r1 (NIST 256-bit) */
- typedef uint8_t nrf_crypto_ecc_secp256r1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp256r1 (NIST 256-bit) */
- /** @brief Variable containing information on secp256r1 (NIST 256-bit).
- *
- * It can be used as a parameter for the functions creating secp256r1 (NIST 256-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256r1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp384r1
- * @{ */
- typedef nrf_crypto_backend_secp384r1_key_pair_generate_context_t
- nrf_crypto_ecc_secp384r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp384r1 (NIST 384-bit). */
- typedef nrf_crypto_backend_secp384r1_public_key_calculate_context_t
- nrf_crypto_ecc_secp384r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp384r1 (NIST 384-bit). */
- typedef nrf_crypto_backend_secp384r1_private_key_t
- nrf_crypto_ecc_secp384r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp384r1 (NIST 384-bit) */
- typedef nrf_crypto_backend_secp384r1_public_key_t
- nrf_crypto_ecc_secp384r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp384r1 (NIST 384-bit) */
- typedef uint8_t nrf_crypto_ecc_secp384r1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP384R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp384r1 (NIST 384-bit) */
- typedef uint8_t nrf_crypto_ecc_secp384r1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP384R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp384r1 (NIST 384-bit) */
- /** @brief Variable containing information on secp384r1 (NIST 384-bit).
- *
- * It can be used as a parameter for the functions creating secp384r1 (NIST 384-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp384r1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp521r1
- * @{ */
- typedef nrf_crypto_backend_secp521r1_key_pair_generate_context_t
- nrf_crypto_ecc_secp521r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp521r1 (NIST 521-bit). */
- typedef nrf_crypto_backend_secp521r1_public_key_calculate_context_t
- nrf_crypto_ecc_secp521r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp521r1 (NIST 521-bit). */
- typedef nrf_crypto_backend_secp521r1_private_key_t
- nrf_crypto_ecc_secp521r1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp521r1 (NIST 521-bit) */
- typedef nrf_crypto_backend_secp521r1_public_key_t
- nrf_crypto_ecc_secp521r1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp521r1 (NIST 521-bit) */
- typedef uint8_t nrf_crypto_ecc_secp521r1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP521R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp521r1 (NIST 521-bit) */
- typedef uint8_t nrf_crypto_ecc_secp521r1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP521R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp521r1 (NIST 521-bit) */
- /** @brief Variable containing information on secp521r1 (NIST 521-bit).
- *
- * It can be used as a parameter for the functions creating secp521r1 (NIST 521-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp521r1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp160k1
- * @{ */
- typedef nrf_crypto_backend_secp160k1_key_pair_generate_context_t
- nrf_crypto_ecc_secp160k1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp160k1 (Koblitz 160-bit). */
- typedef nrf_crypto_backend_secp160k1_public_key_calculate_context_t
- nrf_crypto_ecc_secp160k1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp160k1 (Koblitz 160-bit). */
- typedef nrf_crypto_backend_secp160k1_private_key_t
- nrf_crypto_ecc_secp160k1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp160k1 (Koblitz 160-bit) */
- typedef nrf_crypto_backend_secp160k1_public_key_t
- nrf_crypto_ecc_secp160k1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp160k1 (Koblitz 160-bit) */
- typedef uint8_t nrf_crypto_ecc_secp160k1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP160K1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp160k1 (Koblitz 160-bit) */
- typedef uint8_t nrf_crypto_ecc_secp160k1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP160K1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp160k1 (Koblitz 160-bit) */
- /** @brief Variable containing information on secp160k1 (Koblitz 160-bit).
- *
- * It can be used as a parameter for the functions creating secp160k1 (Koblitz 160-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp160k1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp192k1
- * @{ */
- typedef nrf_crypto_backend_secp192k1_key_pair_generate_context_t
- nrf_crypto_ecc_secp192k1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp192k1 (Koblitz 192-bit). */
- typedef nrf_crypto_backend_secp192k1_public_key_calculate_context_t
- nrf_crypto_ecc_secp192k1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp192k1 (Koblitz 192-bit). */
- typedef nrf_crypto_backend_secp192k1_private_key_t
- nrf_crypto_ecc_secp192k1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp192k1 (Koblitz 192-bit) */
- typedef nrf_crypto_backend_secp192k1_public_key_t
- nrf_crypto_ecc_secp192k1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp192k1 (Koblitz 192-bit) */
- typedef uint8_t nrf_crypto_ecc_secp192k1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP192K1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp192k1 (Koblitz 192-bit) */
- typedef uint8_t nrf_crypto_ecc_secp192k1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP192K1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp192k1 (Koblitz 192-bit) */
- /** @brief Variable containing information on secp192k1 (Koblitz 192-bit).
- *
- * It can be used as a parameter for the functions creating secp192k1 (Koblitz 192-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp192k1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp224k1
- * @{ */
- typedef nrf_crypto_backend_secp224k1_key_pair_generate_context_t
- nrf_crypto_ecc_secp224k1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp224k1 (Koblitz 224-bit). */
- typedef nrf_crypto_backend_secp224k1_public_key_calculate_context_t
- nrf_crypto_ecc_secp224k1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp224k1 (Koblitz 224-bit). */
- typedef nrf_crypto_backend_secp224k1_private_key_t
- nrf_crypto_ecc_secp224k1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp224k1 (Koblitz 224-bit) */
- typedef nrf_crypto_backend_secp224k1_public_key_t
- nrf_crypto_ecc_secp224k1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp224k1 (Koblitz 224-bit) */
- typedef uint8_t nrf_crypto_ecc_secp224k1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP224K1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp224k1 (Koblitz 224-bit) */
- typedef uint8_t nrf_crypto_ecc_secp224k1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP224K1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp224k1 (Koblitz 224-bit) */
- /** @brief Variable containing information on secp224k1 (Koblitz 224-bit).
- *
- * It can be used as a parameter for the functions creating secp224k1 (Koblitz 224-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp224k1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_secp256k1
- * @{ */
- typedef nrf_crypto_backend_secp256k1_key_pair_generate_context_t
- nrf_crypto_ecc_secp256k1_key_pair_generate_context_t; /**< @brief Context structure for key generation using secp256k1 (Koblitz 256-bit). */
- typedef nrf_crypto_backend_secp256k1_public_key_calculate_context_t
- nrf_crypto_ecc_secp256k1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using secp256k1 (Koblitz 256-bit). */
- typedef nrf_crypto_backend_secp256k1_private_key_t
- nrf_crypto_ecc_secp256k1_private_key_t; /**< @brief Structure holding internal representation of a private key for secp256k1 (Koblitz 256-bit) */
- typedef nrf_crypto_backend_secp256k1_public_key_t
- nrf_crypto_ecc_secp256k1_public_key_t; /**< @brief Structure holding internal representation of a public key for secp256k1 (Koblitz 256-bit) */
- typedef uint8_t nrf_crypto_ecc_secp256k1_raw_private_key_t
- [NRF_CRYPTO_ECC_SECP256K1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for secp256k1 (Koblitz 256-bit) */
- typedef uint8_t nrf_crypto_ecc_secp256k1_raw_public_key_t
- [NRF_CRYPTO_ECC_SECP256K1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for secp256k1 (Koblitz 256-bit) */
- /** @brief Variable containing information on secp256k1 (Koblitz 256-bit).
- *
- * It can be used as a parameter for the functions creating secp256k1 (Koblitz 256-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_secp256k1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_bp256r1
- * @{ */
- typedef nrf_crypto_backend_bp256r1_key_pair_generate_context_t
- nrf_crypto_ecc_bp256r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using bp256r1 (Brainpool 256-bit). */
- typedef nrf_crypto_backend_bp256r1_public_key_calculate_context_t
- nrf_crypto_ecc_bp256r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using bp256r1 (Brainpool 256-bit). */
- typedef nrf_crypto_backend_bp256r1_private_key_t
- nrf_crypto_ecc_bp256r1_private_key_t; /**< @brief Structure holding internal representation of a private key for bp256r1 (Brainpool 256-bit) */
- typedef nrf_crypto_backend_bp256r1_public_key_t
- nrf_crypto_ecc_bp256r1_public_key_t; /**< @brief Structure holding internal representation of a public key for bp256r1 (Brainpool 256-bit) */
- typedef uint8_t nrf_crypto_ecc_bp256r1_raw_private_key_t
- [NRF_CRYPTO_ECC_BP256R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for bp256r1 (Brainpool 256-bit) */
- typedef uint8_t nrf_crypto_ecc_bp256r1_raw_public_key_t
- [NRF_CRYPTO_ECC_BP256R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for bp256r1 (Brainpool 256-bit) */
- /** @brief Variable containing information on bp256r1 (Brainpool 256-bit).
- *
- * It can be used as a parameter for the functions creating bp256r1 (Brainpool 256-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_bp256r1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_bp384r1
- * @{ */
- typedef nrf_crypto_backend_bp384r1_key_pair_generate_context_t
- nrf_crypto_ecc_bp384r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using bp384r1 (Brainpool 384-bit). */
- typedef nrf_crypto_backend_bp384r1_public_key_calculate_context_t
- nrf_crypto_ecc_bp384r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using bp384r1 (Brainpool 384-bit). */
- typedef nrf_crypto_backend_bp384r1_private_key_t
- nrf_crypto_ecc_bp384r1_private_key_t; /**< @brief Structure holding internal representation of a private key for bp384r1 (Brainpool 384-bit) */
- typedef nrf_crypto_backend_bp384r1_public_key_t
- nrf_crypto_ecc_bp384r1_public_key_t; /**< @brief Structure holding internal representation of a public key for bp384r1 (Brainpool 384-bit) */
- typedef uint8_t nrf_crypto_ecc_bp384r1_raw_private_key_t
- [NRF_CRYPTO_ECC_BP384R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for bp384r1 (Brainpool 384-bit) */
- typedef uint8_t nrf_crypto_ecc_bp384r1_raw_public_key_t
- [NRF_CRYPTO_ECC_BP384R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for bp384r1 (Brainpool 384-bit) */
- /** @brief Variable containing information on bp384r1 (Brainpool 384-bit).
- *
- * It can be used as a parameter for the functions creating bp384r1 (Brainpool 384-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_bp384r1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_bp512r1
- * @{ */
- typedef nrf_crypto_backend_bp512r1_key_pair_generate_context_t
- nrf_crypto_ecc_bp512r1_key_pair_generate_context_t; /**< @brief Context structure for key generation using bp512r1 (Brainpool 512-bit). */
- typedef nrf_crypto_backend_bp512r1_public_key_calculate_context_t
- nrf_crypto_ecc_bp512r1_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using bp512r1 (Brainpool 512-bit). */
- typedef nrf_crypto_backend_bp512r1_private_key_t
- nrf_crypto_ecc_bp512r1_private_key_t; /**< @brief Structure holding internal representation of a private key for bp512r1 (Brainpool 512-bit) */
- typedef nrf_crypto_backend_bp512r1_public_key_t
- nrf_crypto_ecc_bp512r1_public_key_t; /**< @brief Structure holding internal representation of a public key for bp512r1 (Brainpool 512-bit) */
- typedef uint8_t nrf_crypto_ecc_bp512r1_raw_private_key_t
- [NRF_CRYPTO_ECC_BP512R1_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for bp512r1 (Brainpool 512-bit) */
- typedef uint8_t nrf_crypto_ecc_bp512r1_raw_public_key_t
- [NRF_CRYPTO_ECC_BP512R1_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for bp512r1 (Brainpool 512-bit) */
- /** @brief Variable containing information on bp512r1 (Brainpool 512-bit).
- *
- * It can be used as a parameter for the functions creating bp512r1 (Brainpool 512-bit) keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_bp512r1_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_curve25519
- * @{ */
- typedef nrf_crypto_backend_curve25519_key_pair_generate_context_t
- nrf_crypto_ecc_curve25519_key_pair_generate_context_t; /**< @brief Context structure for key generation using Curve25519. */
- typedef nrf_crypto_backend_curve25519_public_key_calculate_context_t
- nrf_crypto_ecc_curve25519_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using Curve25519. */
- typedef nrf_crypto_backend_curve25519_private_key_t
- nrf_crypto_ecc_curve25519_private_key_t; /**< @brief Structure holding internal representation of a private key for Curve25519 */
- typedef nrf_crypto_backend_curve25519_public_key_t
- nrf_crypto_ecc_curve25519_public_key_t; /**< @brief Structure holding internal representation of a public key for Curve25519 */
- typedef uint8_t nrf_crypto_ecc_curve25519_raw_private_key_t
- [NRF_CRYPTO_ECC_CURVE25519_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for Curve25519 */
- typedef uint8_t nrf_crypto_ecc_curve25519_raw_public_key_t
- [NRF_CRYPTO_ECC_CURVE25519_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for Curve25519 */
- /** @brief Variable containing information on Curve25519.
- *
- * It can be used as a parameter for the functions creating Curve25519 keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_curve25519_curve_info;
- /** @} */
- /** @addtogroup nrf_crypto_ecc_ed25519
- * @{ */
- typedef nrf_crypto_backend_ed25519_key_pair_generate_context_t
- nrf_crypto_ecc_ed25519_key_pair_generate_context_t; /**< @brief Context structure for key generation using Ed25519. */
- typedef nrf_crypto_backend_ed25519_public_key_calculate_context_t
- nrf_crypto_ecc_ed25519_public_key_calculate_context_t; /**< @brief Context structure for public key calculation using Ed25519. */
- typedef nrf_crypto_backend_ed25519_private_key_t
- nrf_crypto_ecc_ed25519_private_key_t; /**< @brief Structure holding internal representation of a private key for Ed25519 */
- typedef nrf_crypto_backend_ed25519_public_key_t
- nrf_crypto_ecc_ed25519_public_key_t; /**< @brief Structure holding internal representation of a public key for Ed25519 */
- typedef uint8_t nrf_crypto_ecc_ed25519_raw_private_key_t
- [NRF_CRYPTO_ECC_ED25519_RAW_PRIVATE_KEY_SIZE]; /**< @brief Array holding raw private key for Ed25519 */
- typedef uint8_t nrf_crypto_ecc_ed25519_raw_public_key_t
- [NRF_CRYPTO_ECC_ED25519_RAW_PUBLIC_KEY_SIZE]; /**< @brief Array holding raw public key for Ed25519 */
- /** @brief Variable containing information on Ed25519.
- *
- * It can be used as a parameter for the functions creating Ed25519 keys.
- */
- extern const nrf_crypto_ecc_curve_info_t g_nrf_crypto_ecc_ed25519_curve_info;
- /** @} */
- typedef uint8_t nrf_crypto_ecc_raw_private_key_t[NRF_CRYPTO_ECC_RAW_PRIVATE_KEY_MAX_SIZE]; /**< @brief Type big enough to hold a raw private key for any the enabled curves. */
- typedef uint8_t nrf_crypto_ecc_raw_public_key_t [NRF_CRYPTO_ECC_RAW_PUBLIC_KEY_MAX_SIZE]; /**< @brief Type big enough to hold a raw public key for any the enabled curves. */
- /** @brief Union holding a context for a key pair generation.
- */
- typedef union
- {
- nrf_crypto_ecc_secp160r1_key_pair_generate_context_t context_secp160r1; /**< @brief Holds context for secp160r1 (NIST 160-bit). */
- nrf_crypto_ecc_secp160r2_key_pair_generate_context_t context_secp160r2; /**< @brief Holds context for secp160r2 (NIST 160-bit). */
- nrf_crypto_ecc_secp192r1_key_pair_generate_context_t context_secp192r1; /**< @brief Holds context for secp192r1 (NIST 192-bit). */
- nrf_crypto_ecc_secp224r1_key_pair_generate_context_t context_secp224r1; /**< @brief Holds context for secp224r1 (NIST 224-bit). */
- nrf_crypto_ecc_secp256r1_key_pair_generate_context_t context_secp256r1; /**< @brief Holds context for secp256r1 (NIST 256-bit). */
- nrf_crypto_ecc_secp384r1_key_pair_generate_context_t context_secp384r1; /**< @brief Holds context for secp384r1 (NIST 384-bit). */
- nrf_crypto_ecc_secp521r1_key_pair_generate_context_t context_secp521r1; /**< @brief Holds context for secp521r1 (NIST 521-bit). */
- nrf_crypto_ecc_secp160k1_key_pair_generate_context_t context_secp160k1; /**< @brief Holds context for secp160k1 (Koblitz 160-bit). */
- nrf_crypto_ecc_secp192k1_key_pair_generate_context_t context_secp192k1; /**< @brief Holds context for secp192k1 (Koblitz 192-bit). */
- nrf_crypto_ecc_secp224k1_key_pair_generate_context_t context_secp224k1; /**< @brief Holds context for secp224k1 (Koblitz 224-bit). */
- nrf_crypto_ecc_secp256k1_key_pair_generate_context_t context_secp256k1; /**< @brief Holds context for secp256k1 (Koblitz 256-bit). */
- nrf_crypto_ecc_bp256r1_key_pair_generate_context_t context_bp256r1; /**< @brief Holds context for bp256r1 (Brainpool 256-bit). */
- nrf_crypto_ecc_bp384r1_key_pair_generate_context_t context_bp384r1; /**< @brief Holds context for bp384r1 (Brainpool 384-bit). */
- nrf_crypto_ecc_bp512r1_key_pair_generate_context_t context_bp512r1; /**< @brief Holds context for bp512r1 (Brainpool 512-bit). */
- nrf_crypto_ecc_curve25519_key_pair_generate_context_t context_curve25519; /**< @brief Holds context for Curve25519. */
- nrf_crypto_ecc_ed25519_key_pair_generate_context_t context_ed25519; /**< @brief Holds context for Ed25519. */
- } nrf_crypto_ecc_key_pair_generate_context_t;
- /** @brief Union holding a context for a public key calculation.
- */
- typedef union
- {
- nrf_crypto_ecc_secp160r1_public_key_calculate_context_t context_secp160r1; /**< @brief Holds context for secp160r1 (NIST 160-bit). */
- nrf_crypto_ecc_secp160r2_public_key_calculate_context_t context_secp160r2; /**< @brief Holds context for secp160r2 (NIST 160-bit). */
- nrf_crypto_ecc_secp192r1_public_key_calculate_context_t context_secp192r1; /**< @brief Holds context for secp192r1 (NIST 192-bit). */
- nrf_crypto_ecc_secp224r1_public_key_calculate_context_t context_secp224r1; /**< @brief Holds context for secp224r1 (NIST 224-bit). */
- nrf_crypto_ecc_secp256r1_public_key_calculate_context_t context_secp256r1; /**< @brief Holds context for secp256r1 (NIST 256-bit). */
- nrf_crypto_ecc_secp384r1_public_key_calculate_context_t context_secp384r1; /**< @brief Holds context for secp384r1 (NIST 384-bit). */
- nrf_crypto_ecc_secp521r1_public_key_calculate_context_t context_secp521r1; /**< @brief Holds context for secp521r1 (NIST 521-bit). */
- nrf_crypto_ecc_secp160k1_public_key_calculate_context_t context_secp160k1; /**< @brief Holds context for secp160k1 (Koblitz 160-bit). */
- nrf_crypto_ecc_secp192k1_public_key_calculate_context_t context_secp192k1; /**< @brief Holds context for secp192k1 (Koblitz 192-bit). */
- nrf_crypto_ecc_secp224k1_public_key_calculate_context_t context_secp224k1; /**< @brief Holds context for secp224k1 (Koblitz 224-bit). */
- nrf_crypto_ecc_secp256k1_public_key_calculate_context_t context_secp256k1; /**< @brief Holds context for secp256k1 (Koblitz 256-bit). */
- nrf_crypto_ecc_bp256r1_public_key_calculate_context_t context_bp256r1; /**< @brief Holds context for bp256r1 (Brainpool 256-bit). */
- nrf_crypto_ecc_bp384r1_public_key_calculate_context_t context_bp384r1; /**< @brief Holds context for bp384r1 (Brainpool 384-bit). */
- nrf_crypto_ecc_bp512r1_public_key_calculate_context_t context_bp512r1; /**< @brief Holds context for bp512r1 (Brainpool 512-bit). */
- nrf_crypto_ecc_curve25519_public_key_calculate_context_t context_curve25519; /**< @brief Holds context for Curve25519. */
- nrf_crypto_ecc_ed25519_public_key_calculate_context_t context_ed25519; /**< @brief Holds context for Ed25519. */
- } nrf_crypto_ecc_public_key_calculate_context_t;
- /** @brief Union holding representation of a private key for any curve type.
- */
- typedef union
- {
- nrf_crypto_ecc_secp160r1_private_key_t key_secp160r1; /**< @brief Holds internal representation of a private key for secp160r1 (NIST 160-bit). */
- nrf_crypto_ecc_secp160r2_private_key_t key_secp160r2; /**< @brief Holds internal representation of a private key for secp160r2 (NIST 160-bit). */
- nrf_crypto_ecc_secp192r1_private_key_t key_secp192r1; /**< @brief Holds internal representation of a private key for secp192r1 (NIST 192-bit). */
- nrf_crypto_ecc_secp224r1_private_key_t key_secp224r1; /**< @brief Holds internal representation of a private key for secp224r1 (NIST 224-bit). */
- nrf_crypto_ecc_secp256r1_private_key_t key_secp256r1; /**< @brief Holds internal representation of a private key for secp256r1 (NIST 256-bit). */
- nrf_crypto_ecc_secp384r1_private_key_t key_secp384r1; /**< @brief Holds internal representation of a private key for secp384r1 (NIST 384-bit). */
- nrf_crypto_ecc_secp521r1_private_key_t key_secp521r1; /**< @brief Holds internal representation of a private key for secp521r1 (NIST 521-bit). */
- nrf_crypto_ecc_secp160k1_private_key_t key_secp160k1; /**< @brief Holds internal representation of a private key for secp160k1 (Koblitz 160-bit). */
- nrf_crypto_ecc_secp192k1_private_key_t key_secp192k1; /**< @brief Holds internal representation of a private key for secp192k1 (Koblitz 192-bit). */
- nrf_crypto_ecc_secp224k1_private_key_t key_secp224k1; /**< @brief Holds internal representation of a private key for secp224k1 (Koblitz 224-bit). */
- nrf_crypto_ecc_secp256k1_private_key_t key_secp256k1; /**< @brief Holds internal representation of a private key for secp256k1 (Koblitz 256-bit). */
- nrf_crypto_ecc_bp256r1_private_key_t key_bp256r1; /**< @brief Holds internal representation of a private key for bp256r1 (Brainpool 256-bit). */
- nrf_crypto_ecc_bp384r1_private_key_t key_bp384r1; /**< @brief Holds internal representation of a private key for bp384r1 (Brainpool 384-bit). */
- nrf_crypto_ecc_bp512r1_private_key_t key_bp512r1; /**< @brief Holds internal representation of a private key for bp512r1 (Brainpool 512-bit). */
- nrf_crypto_ecc_curve25519_private_key_t key_curve25519; /**< @brief Holds internal representation of a private key for Curve25519. */
- nrf_crypto_ecc_ed25519_private_key_t key_ed25519; /**< @brief Holds internal representation of a private key for Ed25519. */
- } nrf_crypto_ecc_private_key_t;
- /** @brief Union holding representation of a public key for any curve type.
- */
- typedef union
- {
- nrf_crypto_ecc_secp160r1_public_key_t key_secp160r1; /**< @brief Holds internal representation of a public key for secp160r1 (NIST 160-bit). */
- nrf_crypto_ecc_secp160r2_public_key_t key_secp160r2; /**< @brief Holds internal representation of a public key for secp160r2 (NIST 160-bit). */
- nrf_crypto_ecc_secp192r1_public_key_t key_secp192r1; /**< @brief Holds internal representation of a public key for secp192r1 (NIST 192-bit). */
- nrf_crypto_ecc_secp224r1_public_key_t key_secp224r1; /**< @brief Holds internal representation of a public key for secp224r1 (NIST 224-bit). */
- nrf_crypto_ecc_secp256r1_public_key_t key_secp256r1; /**< @brief Holds internal representation of a public key for secp256r1 (NIST 256-bit). */
- nrf_crypto_ecc_secp384r1_public_key_t key_secp384r1; /**< @brief Holds internal representation of a public key for secp384r1 (NIST 384-bit). */
- nrf_crypto_ecc_secp521r1_public_key_t key_secp521r1; /**< @brief Holds internal representation of a public key for secp521r1 (NIST 521-bit). */
- nrf_crypto_ecc_secp160k1_public_key_t key_secp160k1; /**< @brief Holds internal representation of a public key for secp160k1 (Koblitz 160-bit). */
- nrf_crypto_ecc_secp192k1_public_key_t key_secp192k1; /**< @brief Holds internal representation of a public key for secp192k1 (Koblitz 192-bit). */
- nrf_crypto_ecc_secp224k1_public_key_t key_secp224k1; /**< @brief Holds internal representation of a public key for secp224k1 (Koblitz 224-bit). */
- nrf_crypto_ecc_secp256k1_public_key_t key_secp256k1; /**< @brief Holds internal representation of a public key for secp256k1 (Koblitz 256-bit). */
- nrf_crypto_ecc_bp256r1_public_key_t key_bp256r1; /**< @brief Holds internal representation of a public key for bp256r1 (Brainpool 256-bit). */
- nrf_crypto_ecc_bp384r1_public_key_t key_bp384r1; /**< @brief Holds internal representation of a public key for bp384r1 (Brainpool 384-bit). */
- nrf_crypto_ecc_bp512r1_public_key_t key_bp512r1; /**< @brief Holds internal representation of a public key for bp512r1 (Brainpool 512-bit). */
- nrf_crypto_ecc_curve25519_public_key_t key_curve25519; /**< @brief Holds internal representation of a public key for Curve25519. */
- nrf_crypto_ecc_ed25519_public_key_t key_ed25519; /**< @brief Holds internal representation of a public key for Ed25519. */
- } nrf_crypto_ecc_public_key_t;
- /** @brief Generate a new pair of a public key and a private key.
- *
- * Generated keys have to deallocated using @ref nrf_crypto_ecc_private_key_free and
- * @ref nrf_crypto_ecc_public_key_free.
- * @param[in] p_context Pointer to temporary structure holding context information.
- * If it is NULL, necessary data will be allocated with
- * @ref NRF_CRYPTO_ALLOC and freed at the end of the function.
- * @param[in] p_curve_info Pointer to information on selected curve. Use only global variables
- * defined by nrf_crypto, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info.
- * @param[out] p_private_key Pointer to structure where newly generated private key will be put.
- * @param[out] p_public_key Pointer to structure where newly generated public key will be put.
- */
- ret_code_t nrf_crypto_ecc_key_pair_generate(
- nrf_crypto_ecc_key_pair_generate_context_t * p_context,
- nrf_crypto_ecc_curve_info_t const * p_curve_info,
- nrf_crypto_ecc_private_key_t * p_private_key,
- nrf_crypto_ecc_public_key_t * p_public_key);
- /** @brief Calculate public key associated with provided private key.
- *
- * Calculated public key has to be deallocated using @ref nrf_crypto_ecc_public_key_free.
- * @param[in] p_context Pointer to temporary structure holding context information.
- * If it is NULL, necessary data will be allocated with
- * @ref NRF_CRYPTO_ALLOC and freed at the end of the function.
- * @param[in] p_private_key Pointer to structure holding a private key that will be used for computation.
- * @param[out] p_public_key Pointer to structure where newly generated public key will be put.
- */
- ret_code_t nrf_crypto_ecc_public_key_calculate(
- nrf_crypto_ecc_public_key_calculate_context_t * p_context,
- nrf_crypto_ecc_private_key_t const * p_private_key,
- nrf_crypto_ecc_public_key_t * p_public_key);
- /** @brief Create a private key from a raw data.
- *
- * Generated private key has to be deallocated using @ref nrf_crypto_ecc_private_key_free.
- *
- * @note Ed25519 only: Memory is allocated internally using @ref nrf_crypto_mem.
- *
- * @param[in] p_curve_info Pointer to information on selected curve. Use only global variables
- * defined by nrf_crypto, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info.
- * @param[out] p_private_key Pointer to structure where newly converted private key will be put.
- * @param[in] p_raw_data Pointer to buffer containing a big endian raw data.
- * @param[in] raw_data_size Number of bytes of a raw data. Correct size for selected curve can be found in
- * @p p_curve_info and it is also defined by the preprocessor definitions, e.g.
- * @ref NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE.
- */
- ret_code_t nrf_crypto_ecc_private_key_from_raw(
- nrf_crypto_ecc_curve_info_t const * p_curve_info,
- nrf_crypto_ecc_private_key_t * p_private_key,
- uint8_t const * p_raw_data,
- size_t raw_data_size);
- /** @brief Convert a private key to a raw data.
- *
- * @param[in] p_private_key Pointer to structure holding private key that will be convert.
- * @param[out] p_raw_data Pointer to buffer containing a big endian raw data.
- * @param[in,out] p_raw_data_size Maximum number of bytes that @p p_raw_data buffer can hold on input
- * and the actual number of bytes used by the raw data on output.
- * Actual size for selected curve can be found in
- * @ref nrf_crypto_ecc_curve_info_t and it is also defined by
- * the preprocessor definitions, e.g.
- * @ref NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE.
- */
- ret_code_t nrf_crypto_ecc_private_key_to_raw(
- nrf_crypto_ecc_private_key_t const * p_private_key,
- uint8_t * p_raw_data,
- size_t * p_raw_data_size);
- /** @brief Create a public key from a raw data.
- *
- * Generated public key has to be deallocated using @ref nrf_crypto_ecc_public_key_free.
- * @param[in] p_curve_info Pointer to information on selected curve. Use only global variables
- * defined by nrf_crypto, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info.
- * @param[out] p_public_key Pointer to structure where newly converted public key will be put.
- * @param[in] p_raw_data Pointer to buffer containing a big endian raw data.
- * @param[in] raw_data_size Number of bytes of a raw data. Correct size for selected curve can be found in
- * @p p_curve_info and it is also defined by the preprocessor definitions, e.g.
- * @ref NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE.
- */
- ret_code_t nrf_crypto_ecc_public_key_from_raw(
- nrf_crypto_ecc_curve_info_t const * p_curve_info,
- nrf_crypto_ecc_public_key_t * p_public_key,
- uint8_t const * p_raw_data,
- size_t raw_data_size);
- /** @brief Convert a public key to a raw data.
- *
- * @param[in] p_public_key Pointer to structure holding public key that will be convert.
- * @param[out] p_raw_data Pointer to buffer containing a big endian raw data.
- * @param[in,out] p_raw_data_size Maximum number of bytes that @p p_raw_data buffer can hold on input
- * and the actual number of bytes used by the raw data on output.
- * Actual size for selected curve can be found in
- * @ref nrf_crypto_ecc_curve_info_t and it is also defined by
- * the preprocessor definitions, e.g.
- * @ref NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE.
- */
- ret_code_t nrf_crypto_ecc_public_key_to_raw(
- nrf_crypto_ecc_public_key_t const * p_public_key,
- uint8_t * p_raw_data,
- size_t * p_raw_data_size);
- /** @brief Release resources taken by a private key.
- *
- * @param[in] p_private_key Pointer to structure holding private key to release.
- */
- ret_code_t nrf_crypto_ecc_private_key_free(
- nrf_crypto_ecc_private_key_t * p_private_key);
- /** @brief Release resources taken by a public key.
- *
- * @param[in] p_public_key Pointer to structure holding public key to release.
- */
- ret_code_t nrf_crypto_ecc_public_key_free(
- nrf_crypto_ecc_public_key_t * p_public_key);
- /** @brief Gets curve information structure from provided key (private or public).
- *
- * @param[in] p_key Pointer to structure holding private or public key.
- * @param[out] pp_curve_info Pointer to location where put retrieved pointer to curve information structure.
- */
- ret_code_t nrf_crypto_ecc_curve_info_get(
- void const * p_key,
- nrf_crypto_ecc_curve_info_t const ** pp_curve_info);
- /** @brief Inverts byte order of a big integers contained in a raw data.
- *
- * All the ECC API accepts only data with big endian integers, so this function have to be used
- * if little endian is required. If input is in little endian byte order it will be converted
- * to big endian. If input is in big endian byte order it will be converted to little endian.
- * It works for ECC raw private key, raw public key, signature and shared secret. If raw data
- * contains two big integers (e.g. R, S, or X, Y) each integer is inverted separately.
- * If @p p_curve_info is NULL then all bytes in buffer will be inverted regardless what is the
- * content of the buffer.
- *
- * @param[in] p_curve_info Pointer to information on selected curve. Use only global variables
- * defined by nrf_crypto, e.g. @ref g_nrf_crypto_ecc_secp256r1_curve_info.
- * @param[in] p_raw_input Pointer to buffer holding source data.
- * @param[out] p_raw_output Pointer to buffer that will be filled with inverted byte order.
- * This parameter can be the same as @p p_raw_input, otherwise the
- * buffers cannot overlap.
- * @param[in] raw_data_size Size of input and output buffer.
- */
- ret_code_t nrf_crypto_ecc_byte_order_invert(
- nrf_crypto_ecc_curve_info_t const * p_curve_info,
- uint8_t const * p_raw_input,
- uint8_t * p_raw_output,
- size_t raw_data_size);
- #ifdef __cplusplus
- }
- #endif
- /** @}
- * @}
- */
- #endif // NRF_CRYPTO_ECC_H__
|