ECC (Elliptic Curve Cryptography) More...
#include "core/crypto.h"Go to the source code of this file.
Data Structures | |
| struct | EcPoint |
| EC point (affine coordinates) More... | |
| struct | EcPoint3 |
| EC point (projective coordinates) More... | |
| struct | EcPublicKey |
| EC public key. More... | |
| struct | EcPrivateKey |
| EC private key. More... | |
| struct | EcState |
| Working state (point addition/subtraction/doubling) More... | |
| struct | EcMulFastState |
| Working state (fast scalar multiplication) More... | |
| struct | EcMulRegularState |
| Working state (regular scalar multiplication) More... | |
| struct | EcTwinMulState |
| Working state (twin multiplication) More... | |
| struct | _EcCurve |
| Elliptic curve parameters. More... | |
Typedefs | |
| typedef void(* | EcModAlgo) (const EcCurve *curve, uint32_t *r, const uint32_t *a) |
| Modular reduction. More... | |
| typedef void(* | EcInvModAlgo) (const EcCurve *curve, uint32_t *r, const uint32_t *a) |
| Modular inverse. More... | |
Enumerations | |
| enum | EcCurveType { EC_CURVE_TYPE_WEIERSTRASS = 1, EC_CURVE_TYPE_WEIERSTRASS_A0 = 2, EC_CURVE_TYPE_WEIERSTRASS_A3 = 3, EC_CURVE_TYPE_MONTGOMERY = 4, EC_CURVE_TYPE_EDWARDS = 5 } |
| Elliptic curve type. More... | |
| enum | EcPointFormat { EC_POINT_FORMAT_COMPRESSED_EVEN = 0x02, EC_POINT_FORMAT_COMPRESSED_ODD = 0x03, EC_POINT_FORMAT_UNCOMPRESSED = 0x04 } |
| EC point format. More... | |
| enum | EcPublicKeyFormat { EC_PUBLIC_KEY_FORMAT_X963 = 0, EC_PUBLIC_KEY_FORMAT_RAW = 1, EC_PUBLIC_KEY_FORMAT_RAW_X = 2, EC_PUBLIC_KEY_FORMAT_RAW_Y = 3 } |
| EC public key format. More... | |
Functions | |
| void | ecInitPublicKey (EcPublicKey *key) |
| Initialize an EC public key. More... | |
| void | ecFreePublicKey (EcPublicKey *key) |
| Release an EC public key. More... | |
| void | ecInitPrivateKey (EcPrivateKey *key) |
| Initialize an EC private key. More... | |
| void | ecFreePrivateKey (EcPrivateKey *key) |
| Release an EC private key. More... | |
| error_t | ecGenerateKeyPair (const PrngAlgo *prngAlgo, void *prngContext, const EcCurve *curve, EcPrivateKey *privateKey, EcPublicKey *publicKey) |
| EC key pair generation. More... | |
| error_t | ecGeneratePrivateKey (const PrngAlgo *prngAlgo, void *prngContext, const EcCurve *curve, EcPrivateKey *privateKey) |
| EC private key generation. More... | |
| error_t | ecGeneratePublicKey (const EcPrivateKey *privateKey, EcPublicKey *publicKey) |
| Derive the public key from an EC private key. More... | |
| error_t | ecImportPublicKey (EcPublicKey *key, const EcCurve *curve, const uint8_t *input, size_t length, EcPublicKeyFormat format) |
| Import an EC public key. More... | |
| error_t | ecExportPublicKey (const EcPublicKey *key, uint8_t *output, size_t *written, EcPublicKeyFormat format) |
| Export an EC public key. More... | |
| error_t | ecImportPrivateKey (EcPrivateKey *key, const EcCurve *curve, const uint8_t *input, size_t length) |
| Import an EC private key. More... | |
| error_t | ecExportPrivateKey (const EcPrivateKey *key, uint8_t *output, size_t *written) |
| Export an EC private key. More... | |
| error_t | ecImportPoint (const EcCurve *curve, EcPoint *r, const uint8_t *input, size_t length) |
| Convert an octet string to an EC point. More... | |
| error_t | ecExportPoint (const EcCurve *curve, const EcPoint *a, uint8_t *output, size_t *written) |
| Convert an EC point to an octet string. More... | |
| void | ecProjectify (const EcCurve *curve, EcPoint3 *r, const EcPoint *s) |
| Compute projective representation. More... | |
| error_t | ecAffinify (const EcCurve *curve, EcPoint3 *r, const EcPoint3 *s) |
| Recover affine representation. More... | |
| bool_t | ecIsPointAffine (const EcCurve *curve, const EcPoint *s) |
| Check whether the affine point S is on the curve. More... | |
| void | ecDouble (EcState *state, EcPoint3 *r, const EcPoint3 *s) |
| Point doubling. More... | |
| void | ecAdd (EcState *state, EcPoint3 *r, const EcPoint3 *s, const EcPoint3 *t) |
| Point addition (helper routine) More... | |
| void | ecFullAdd (EcState *state, EcPoint3 *r, const EcPoint3 *s, const EcPoint3 *t) |
| Point addition. More... | |
| void | ecFullSub (EcState *state, EcPoint3 *r, const EcPoint3 *s, const EcPoint3 *t) |
| Point subtraction. More... | |
| error_t | ecMulFast (const EcCurve *curve, EcPoint3 *r, const uint32_t *d, const EcPoint3 *s) |
| Scalar multiplication (fast calculation) More... | |
| error_t | ecMulRegular (const EcCurve *curve, EcPoint3 *r, const uint32_t *d, const EcPoint3 *s) |
| Scalar multiplication (regular calculation) More... | |
| error_t | ecTwinMul (const EcCurve *curve, EcPoint3 *r, const uint32_t *d0, const EcPoint3 *s, const uint32_t *d1, const EcPoint3 *t) |
| Twin multiplication. More... | |
Variables | |
| const uint8_t | EC_PUBLIC_KEY_OID [7] |
Detailed Description
ECC (Elliptic Curve Cryptography)
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneCRYPTO Open.
This program 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 2 of the License, or (at your option) any later version.
This program 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 a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.5.4
Definition in file ec.h.
Macro Definition Documentation
◆ BRAINPOOLP160R1_SUPPORT
◆ BRAINPOOLP160T1_SUPPORT
◆ BRAINPOOLP192R1_SUPPORT
◆ BRAINPOOLP192T1_SUPPORT
◆ BRAINPOOLP224R1_SUPPORT
◆ BRAINPOOLP224T1_SUPPORT
◆ BRAINPOOLP256R1_SUPPORT
◆ BRAINPOOLP256T1_SUPPORT
◆ BRAINPOOLP320R1_SUPPORT
◆ BRAINPOOLP320T1_SUPPORT
◆ BRAINPOOLP384R1_SUPPORT
◆ BRAINPOOLP384T1_SUPPORT
◆ BRAINPOOLP512R1_SUPPORT
◆ BRAINPOOLP512T1_SUPPORT
◆ EC_MAX_MODULUS_SIZE
◆ EC_MAX_ORDER_SIZE
◆ EcCurve
◆ ED25519_SUPPORT
◆ ED448_SUPPORT
◆ FRP256V1_SUPPORT
◆ SECP112R1_SUPPORT
◆ SECP112R2_SUPPORT
◆ SECP128R1_SUPPORT
◆ SECP128R2_SUPPORT
◆ SECP160K1_SUPPORT
◆ SECP160R1_SUPPORT
◆ SECP160R2_SUPPORT
◆ SECP192K1_SUPPORT
◆ SECP192R1_SUPPORT
◆ SECP224K1_SUPPORT
◆ SECP224R1_SUPPORT
◆ SECP256K1_SUPPORT
◆ SECP256R1_SUPPORT
◆ SECP384R1_SUPPORT
◆ SECP521R1_SUPPORT
◆ SM2_SUPPORT
◆ X25519_SUPPORT
◆ X448_SUPPORT
Typedef Documentation
◆ EcInvModAlgo
◆ EcModAlgo
Enumeration Type Documentation
◆ EcCurveType
| enum EcCurveType |
◆ EcPointFormat
| enum EcPointFormat |
◆ EcPublicKeyFormat
| enum EcPublicKeyFormat |
Function Documentation
◆ ecAdd()
◆ ecAffinify()
◆ ecDouble()
◆ ecExportPoint()
◆ ecExportPrivateKey()
| error_t ecExportPrivateKey | ( | const EcPrivateKey * | key, |
| uint8_t * | output, | ||
| size_t * | written | ||
| ) |
◆ ecExportPublicKey()
| error_t ecExportPublicKey | ( | const EcPublicKey * | key, |
| uint8_t * | output, | ||
| size_t * | written, | ||
| EcPublicKeyFormat | format | ||
| ) |
◆ ecFreePrivateKey()
| void ecFreePrivateKey | ( | EcPrivateKey * | key | ) |
◆ ecFreePublicKey()
| void ecFreePublicKey | ( | EcPublicKey * | key | ) |
◆ ecFullAdd()
◆ ecFullSub()
◆ ecGenerateKeyPair()
| error_t ecGenerateKeyPair | ( | const PrngAlgo * | prngAlgo, |
| void * | prngContext, | ||
| const EcCurve * | curve, | ||
| EcPrivateKey * | privateKey, | ||
| EcPublicKey * | publicKey | ||
| ) |
◆ ecGeneratePrivateKey()
| error_t ecGeneratePrivateKey | ( | const PrngAlgo * | prngAlgo, |
| void * | prngContext, | ||
| const EcCurve * | curve, | ||
| EcPrivateKey * | privateKey | ||
| ) |
◆ ecGeneratePublicKey()
| error_t ecGeneratePublicKey | ( | const EcPrivateKey * | privateKey, |
| EcPublicKey * | publicKey | ||
| ) |
◆ ecImportPoint()
◆ ecImportPrivateKey()
| error_t ecImportPrivateKey | ( | EcPrivateKey * | key, |
| const EcCurve * | curve, | ||
| const uint8_t * | input, | ||
| size_t | length | ||
| ) |
◆ ecImportPublicKey()
| error_t ecImportPublicKey | ( | EcPublicKey * | key, |
| const EcCurve * | curve, | ||
| const uint8_t * | input, | ||
| size_t | length, | ||
| EcPublicKeyFormat | format | ||
| ) |
◆ ecInitPrivateKey()
| void ecInitPrivateKey | ( | EcPrivateKey * | key | ) |
◆ ecInitPublicKey()
| void ecInitPublicKey | ( | EcPublicKey * | key | ) |
◆ ecIsPointAffine()
◆ ecMulFast()
Scalar multiplication (fast calculation)
- Parameters
-
[in] curve Elliptic curve parameters [out] r Resulting point R = d.S [in] d An integer d such as 0 <= d < q [in] s EC point
- Returns
- Error code
- Parameters
-
[in] curve Elliptic curve parameters [out] r Resulting point R = d.S [in] d An integer d such as 0 <= d < p [in] s EC point
- Returns
- Error code
◆ ecMulRegular()
◆ ecProjectify()
◆ ecTwinMul()
| error_t ecTwinMul | ( | const EcCurve * | curve, |
| EcPoint3 * | r, | ||
| const uint32_t * | d0, | ||
| const EcPoint3 * | s, | ||
| const uint32_t * | d1, | ||
| const EcPoint3 * | t | ||
| ) |
Twin multiplication.
- Parameters
-
[in] curve Elliptic curve parameters [out] r Resulting point R = d0.S + d1.T [in] d0 An integer d such as 0 <= d0 < q [in] s EC point [in] d1 An integer d such as 0 <= d1 < q [in] t EC point
- Returns
- Error code
- Parameters
-
[in] curve Elliptic curve parameters [out] r Resulting point R = d0.S + d1.T [in] d0 An integer d such as 0 <= d0 < p [in] s EC point [in] d1 An integer d such as 0 <= d1 < p [in] t EC point
- Returns
- Error code
