API

Data Structures

struct  C4eElement
 Element of a set/field, a big number or binary polynomial. More...

Modules

 Architecture
 Symmetric Ciphers
 Discrete Logarithm Cryptography (DLC)
 

Fundamental declarations and definitions for algorithms based on discrete logarithm problem.


 Elliptic Curve Cryptography (ECC)
 Hash
 Random
 RSA

Defines

#define C4E_FALSE
#define C4E_TRUE

Typedefs

typedef C4eArchUint C4eSysStatus
typedef int C4eSysBool
 Boolean type.

Functions

void c4e_elem_os2e (C4E_CONST C4eArchUint8 *C4E_RESTRICT osp, C4eArchSize len, C4eElement *C4E_RESTRICT elem)
 Octet string to element conversion primitive, according to IEEE Std 1363, section 5.5 and NIST SP800-56A, appendix C.
C4eArchSize c4e_elem_e2os (C4E_CONST C4eElement *C4E_RESTRICT elem, C4eArchSize bufsize, C4eArchUint8 *C4E_RESTRICT buf)
 Element to octet string conversion primitive, according to IEEE Std 1363, section 5.5 and NIST SP800-56A, appendix C.

Error Numbers



#define C4E_STATUS_OK
#define C4E_STATUS_ERNG
#define C4E_STATUS_EMOD
#define C4E_STATUS_EKEYPRV
#define C4E_STATUS_EKEYPUB
#define C4E_STATUS_ELENGTH
#define C4E_STATUS_ECODING
#define C4E_STATUS_EASN1
#define C4E_STATUS_EVERIFY
#define C4E_STATUS_EDOM
#define C4E_STATUS_ERANGE

Define Documentation

#define C4E_FALSE

Boolean false

See also:
C4eSysBool

Definition at line 69 of file c4e_sys.h.

#define C4E_TRUE

Boolean true

See also:
C4eSysBool

Definition at line 70 of file c4e_sys.h.

#define C4E_STATUS_OK

C4eSysStatus: success

Definition at line 82 of file c4e_sys.h.

#define C4E_STATUS_ERNG

C4eSysStatus: RNG fault

Definition at line 83 of file c4e_sys.h.

#define C4E_STATUS_EMOD

C4eSysStatus: wrong modulus

Definition at line 84 of file c4e_sys.h.

#define C4E_STATUS_EKEYPRV

C4eSysStatus: wrong private key, respective CRT coefficient

Definition at line 85 of file c4e_sys.h.

#define C4E_STATUS_EKEYPUB

C4eSysStatus: wrong public key

Definition at line 86 of file c4e_sys.h.

#define C4E_STATUS_ELENGTH

C4eSysStatus: octet string length error (digest, signature, plain/cipher block)

Definition at line 87 of file c4e_sys.h.

#define C4E_STATUS_ECODING

C4eSysStatus: encoding (padding) error

Definition at line 88 of file c4e_sys.h.

#define C4E_STATUS_EASN1

C4eSysStatus: ASN.1 decoding error

Definition at line 89 of file c4e_sys.h.

#define C4E_STATUS_EVERIFY

C4eSysStatus: signature verification error

Definition at line 90 of file c4e_sys.h.

#define C4E_STATUS_EDOM

C4eSysStatus: no result/solution in group/field (domain)

Definition at line 91 of file c4e_sys.h.

#define C4E_STATUS_ERANGE

C4eSysStatus: big number or polynomial out of range

Definition at line 92 of file c4e_sys.h.


Typedef Documentation

Return status, e.g. C4E_STATUS_OK

Definition at line 46 of file c4e_sys.h.

Boolean type.

See also:
C4E_TRUE, C4E_FALSE

Definition at line 54 of file c4e_sys.h.


Function Documentation

void c4e_elem_os2e ( C4E_CONST C4eArchUint8 *C4E_RESTRICT  osp,
C4eArchSize  len,
C4eElement *C4E_RESTRICT  elem 
)

Octet string to element conversion primitive, according to IEEE Std 1363, section 5.5 and NIST SP800-56A, appendix C.

Converts a big number or binary polynomial (set/field element) from octet string (in network byte order) to internal representation.

Note:
If len is shorter than the number osp represents then the least-significant bits/bytes are lost.
Precondition:
The size of buffer elem->digits (in number of digits according to elem->size) must be at least:
Postcondition:
Element elem is normalized.
Bibliography:
Standard Specifications For Public-Key Cryptography. Std 1363-2000, IEEE, 2000.
Bibliography:
NIST Special Publication 800-56A Revision 2: Recommendation for Pair-Wise Key Establishment Schemes Using Discrete Logarithm Cryptography. 2013.
Parameters:
[in] osp Octet string pointer (network byte order, means most significant byte at lowest position).
[in] len Number of bytes in osp array (octet string). If len is zero, then elem becomes number zero.
[out] elem Pointer to set/field element (least significant digit first, means at lowest position)
See also:
C4eElement, C4E_ELEM_DIGITS_NUM(), C4E_ELEM_ASGN_MEM()
C4eArchSize c4e_elem_e2os ( C4E_CONST C4eElement *C4E_RESTRICT  elem,
C4eArchSize  bufsize,
C4eArchUint8 *C4E_RESTRICT  buf 
)

Element to octet string conversion primitive, according to IEEE Std 1363, section 5.5 and NIST SP800-56A, appendix C.

Converts a big number or binary polynomial (set/field element) from internal representation into an octet string, where the first octet/byte (located at address buf) has most significance (network byte order). More control allows parameter bufsize:

  • if bufsize is zero, then the converted element in buf will be normalized (the smallest representation of elem without leading zeros);
  • if bufsize is less than the number of bytes needed for a normalized representation of elem, then the converted element in buf is truncated (and so may be unusual);
  • if bufsize is greater then the number of bytes needed for a normalized representation of elem, then the leading bytes are filled with zero.
Bibliography:
Standard Specifications For Public-Key Cryptography. Std 1363-2000, IEEE, 2000.
Bibliography:
NIST Special Publication 800-56A Revision 2: Recommendation for Pair-Wise Key Establishment Schemes Using Discrete Logarithm Cryptography. 2013.
Parameters:
[in] elem Pointer to set/field element to be converted.
[in] bufsize Number of bytes expected in buffer buf.
[out] buf Output buffer, getting converted element elem in network byte order (most significant byte first, means at lowest address).
Returns:
Number of bytes to represent elem. In case bufsize was greater than zero, then:
  • the converted element in buf was truncated, if the return value is greater than bufsize;
  • the converted element in buf is filled with leading zeros up to bufsize, if the return value is less/equal than bufsize.
See also:
C4eElement, C4eElemOsp, C4E_ELEM_ASGN_MEM()