Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

ec.h File Reference

ec.h File Reference

ECC (Elliptic Curve Cryptography) More...

Go to the source code of this file.

Data Structures

struct  EcPoint
 Elliptic curve point. More...
struct  EcDomainParameters
 EC domain parameters. More...

Functions

void ecInitDomainParameters (EcDomainParameters *params)
 Initialize EC domain parameters.
void ecFreeDomainParameters (EcDomainParameters *params)
 Release EC domain parameters.
error_t ecLoadDomainParameters (EcDomainParameters *params, const EcCurveInfo *curveInfo)
 Load EC domain parameters.
void ecInit (EcPoint *r)
 Initialize elliptic curve point.
void ecFree (EcPoint *r)
 Release an elliptic curve point.
error_t ecCopy (EcPoint *r, const EcPoint *s)
 Copy EC point.
error_t ecImport (const EcDomainParameters *params, EcPoint *r, const uint8_t *data, size_t length)
 Convert an octet string to an EC point.
error_t ecExport (const EcDomainParameters *params, const EcPoint *a, uint8_t *data, size_t *length)
 Convert an EC point to an octet string.
error_t ecProjectify (const EcDomainParameters *params, EcPoint *r, const EcPoint *s)
 Compute projective representation.
error_t ecAffinify (const EcDomainParameters *params, EcPoint *r, const EcPoint *s)
 Recover affine representation.
bool_t ecIsPointAffine (const EcDomainParameters *params, const EcPoint *s)
 Check whether the affine point S is on the curve.
error_t ecDouble (const EcDomainParameters *params, EcPoint *r, const EcPoint *s)
 Point doubling.
error_t ecAdd (const EcDomainParameters *params, EcPoint *r, const EcPoint *s, const EcPoint *t)
 Point addition (helper routine)
error_t ecFullAdd (const EcDomainParameters *params, EcPoint *r, const EcPoint *s, const EcPoint *t)
 Point addition.
error_t ecFullSub (const EcDomainParameters *params, EcPoint *r, const EcPoint *s, const EcPoint *t)
 Point subtraction.
error_t ecMult (const EcDomainParameters *params, EcPoint *r, const Mpi *d, const EcPoint *s)
 Scalar multiplication.
error_t ecTwinMult (const EcDomainParameters *params, EcPoint *r, const Mpi *d0, const EcPoint *s, const Mpi *d1, const EcPoint *t)
 Twin multiplication.
error_t ecAddMod (const EcDomainParameters *params, Mpi *r, const Mpi *a, const Mpi *b)
 Fast modular addition.
error_t ecSubMod (const EcDomainParameters *params, Mpi *r, const Mpi *a, const Mpi *b)
 Fast modular subtraction.
error_t ecMulMod (const EcDomainParameters *params, Mpi *r, const Mpi *a, const Mpi *b)
 Fast modular multiplication.
error_t ecSqrMod (const EcDomainParameters *params, Mpi *r, const Mpi *a)
 Fast modular squaring.

Detailed Description

ECC (Elliptic Curve Cryptography)

License

Copyright (C) 2010-2017 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.

Author:
Oryx Embedded SARL (www.oryx-embedded.com)
Version:
1.7.6

Definition in file ec.h.


Function Documentation

error_t ecAdd ( const EcDomainParameters params,
EcPoint r,
const EcPoint s,
const EcPoint t 
)

Point addition (helper routine)

Parameters:
[in]paramsEC domain parameters
[out]rResulting point R = S + T
[in]sFirst operand
[in]tSecond operand
Returns:
Error code

Definition at line 523 of file ec.c.

error_t ecAddMod ( const EcDomainParameters params,
Mpi r,
const Mpi a,
const Mpi b 
)

Fast modular addition.

Parameters:
[in]paramsEC domain parameters
[out]rResulting integer R = (A + B) mod p
[in]aAn integer such as 0 <= A < p
[in]bAn integer such as 0 <= B < p
Returns:
Error code

Definition at line 1049 of file ec.c.

error_t ecAffinify ( const EcDomainParameters params,
EcPoint r,
const EcPoint s 
)

Recover affine representation.

Parameters:
[in]paramsEC domain parameters
[out]rAffine representation of the point
[in]sProjective representation of the point
Returns:
Error code

Definition at line 305 of file ec.c.

error_t ecCopy ( EcPoint r,
const EcPoint s 
)

Copy EC point.

Parameters:
[out]rDestination EC point
[in]sSource EC point
Returns:
Error code

Definition at line 172 of file ec.c.

error_t ecDouble ( const EcDomainParameters params,
EcPoint r,
const EcPoint s 
)

Point doubling.

Parameters:
[in]paramsEC domain parameters
[out]rResulting point R = 2S
[in]sPoint S
Returns:
Error code

Definition at line 392 of file ec.c.

error_t ecExport ( const EcDomainParameters params,
const EcPoint a,
uint8_t *  data,
size_t *  length 
)

Convert an EC point to an octet string.

Parameters:
[in]paramsEC domain parameters
[in]aEC point to be converted
[out]dataPointer to the octet string
[out]lengthLength of the resulting octet string
Returns:
Error code

Definition at line 243 of file ec.c.

void ecFree ( EcPoint r )

Release an elliptic curve point.

Parameters:
[in,out]rPointer to the EC point to initialize to free

Definition at line 156 of file ec.c.

void ecFreeDomainParameters ( EcDomainParameters params )

Release EC domain parameters.

Parameters:
[in]paramsPointer to the EC domain parameters to free

Definition at line 70 of file ec.c.

error_t ecFullAdd ( const EcDomainParameters params,
EcPoint r,
const EcPoint s,
const EcPoint t 
)

Point addition.

Parameters:
[in]paramsEC domain parameters
[out]rResulting point R = S + T
[in]sFirst operand
[in]tSecond operand
Returns:
Error code

Definition at line 682 of file ec.c.

error_t ecFullSub ( const EcDomainParameters params,
EcPoint r,
const EcPoint s,
const EcPoint t 
)

Point subtraction.

Parameters:
[in]paramsEC domain parameters
[out]rResulting point R = S - T
[in]sFirst operand
[in]tSecond operand
Returns:
Error code

Definition at line 730 of file ec.c.

error_t ecImport ( const EcDomainParameters params,
EcPoint r,
const uint8_t *  data,
size_t  length 
)

Convert an octet string to an EC point.

Parameters:
[in]paramsEC domain parameters
[out]rEC point resulting from the conversion
[in]dataPointer to the octet string
[in]lengthLength of the octet string
Returns:
Error code

Definition at line 200 of file ec.c.

void ecInit ( EcPoint r )

Initialize elliptic curve point.

Parameters:
[in,out]rPointer to the EC point to be initialized

Definition at line 142 of file ec.c.

void ecInitDomainParameters ( EcDomainParameters params )

Initialize EC domain parameters.

Parameters:
[in]paramsPointer to the EC domain parameters to be initialized

Definition at line 50 of file ec.c.

bool_t ecIsPointAffine ( const EcDomainParameters params,
const EcPoint s 
)

Check whether the affine point S is on the curve.

Parameters:
[in]paramsEC domain parameters
[in]sAffine representation of the point
Returns:
TRUE if the affine point S is on the curve, else FALSE

Definition at line 350 of file ec.c.

error_t ecLoadDomainParameters ( EcDomainParameters params,
const EcCurveInfo curveInfo 
)

Load EC domain parameters.

Parameters:
[out]paramsPointer to the structure to be initialized
[in]curveInfoElliptic curve parameters
Returns:
Error code

Definition at line 88 of file ec.c.

error_t ecMulMod ( const EcDomainParameters params,
Mpi r,
const Mpi a,
const Mpi b 
)

Fast modular multiplication.

Parameters:
[in]paramsEC domain parameters
[out]rResulting integer R = (A * B) mod p
[in]aAn integer such as 0 <= A < p
[in]bAn integer such as 0 <= B < p
Returns:
Error code

Definition at line 1105 of file ec.c.

error_t ecMult ( const EcDomainParameters params,
EcPoint r,
const Mpi d,
const EcPoint s 
)

Scalar multiplication.

Parameters:
[in]paramsEC domain parameters
[out]rResulting point R = d.S
[in]dAn integer d such as 0 <= d < p
[in]sEC point
Returns:
Error code

Definition at line 765 of file ec.c.

error_t ecProjectify ( const EcDomainParameters params,
EcPoint r,
const EcPoint s 
)

Compute projective representation.

Parameters:
[in]paramsEC domain parameters
[out]rProjective representation of the point
[in]sAffine representation of the point
Returns:
Error code

Definition at line 282 of file ec.c.

error_t ecSqrMod ( const EcDomainParameters params,
Mpi r,
const Mpi a 
)

Fast modular squaring.

Parameters:
[in]paramsEC domain parameters
[out]rResulting integer R = (A ^ 2) mod p
[in]aAn integer such as 0 <= A < p
Returns:
Error code

Definition at line 1136 of file ec.c.

error_t ecSubMod ( const EcDomainParameters params,
Mpi r,
const Mpi a,
const Mpi b 
)

Fast modular subtraction.

Parameters:
[in]paramsEC domain parameters
[out]rResulting integer R = (A - B) mod p
[in]aAn integer such as 0 <= A < p
[in]bAn integer such as 0 <= B < p
Returns:
Error code

Definition at line 1077 of file ec.c.

error_t ecTwinMult ( const EcDomainParameters params,
EcPoint r,
const Mpi d0,
const EcPoint s,
const Mpi d1,
const EcPoint t 
)

Twin multiplication.

Parameters:
[in]paramsEC domain parameters
[out]rResulting point R = d0.S + d1.T
[in]d0An integer d such as 0 <= d0 < p
[in]sEC point
[in]d1An integer d such as 0 <= d1 < p
[in]tEC point
Returns:
Error code

Definition at line 897 of file ec.c.