File: api.html

package info (click to toggle)
beecrypt 2.2.0-pre1-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,820 kB
  • ctags: 1,325
  • sloc: ansic: 12,215; sh: 9,073; asm: 2,715; makefile: 80
file content (133 lines) | stat: -rw-r--r-- 4,199 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<LINK REL=StyleSheet HREF="manual.css" TYPE="text/css">
<TITLE>The BeeCrypt API</TITLE>
</HEAD>
<BODY>
<DL>
<DT><B>Entropy Sources</B></DT>
<DD>
<BR>
<HR>
</DD>
<DT><B>Random Generators</B></DT>
<DD>
<P>The following structure is used to hold information describing a
specific random generator implementation:
<BR><A NAME="randomGenerator"></A><PRE><CODE CLASS=c>
typedef struct
{
  const char*                  name;
  const unsigned int           paramsize;
  const randomGeneratorSetup   setup;
  const randomGeneratorSeed    seed;
  const randomGeneratorNext    next;
  const randomGeneratorCleanup cleanup;
} randomGenerator;
</CODE></PRE>
<P>The following structure is used to work with a specific random
generator implementation: 
<BR><A NAME="randomGeneratorContext"></A><PRE><CODE CLASS=c>
typedef struct
{
  const randomGenerator* rng;
  randomGeneratorparam*  param;
} randomGeneratorContext;
</CODE></PRE>
<P>The following functions will operate on this structure:
<DL>
<DT><A NAME="randomGeneratorContextInit"></A><CODE CLASS=c>
void randomGeneratorContextInit(<A HREF="#randomGeneratorContext">randomGeneratorContext</A>* ctxt, const <A HREF="#randomGenerator">randomGenerator</A>* rng);
</CODE></DT>
<DD>This function initializes <CODE>ctxt</CODE> by allocating and
initializing parameters appropriate for <CODE>rng</CODE>.
</DD>
<DT><A NAME="randomGeneratorContextFree"></A><CODE CLASS=c>
void randomGeneratorContextFree(<A HREF="#randomGeneratorContext">randomGeneratorContext</A>* ctxt);
</CODE></DT>
<DD>This function cleans up <CODE>ctxt</CODE> and frees its
allocated parameters.
</DL>
<BR>
<HR>
</DD>
<DT><B>Hash Functions</B></DT>
<DD>
<BR>
<HR>
</DD>
<DT><B>Keyed Hash Functions</B></DT>
<DD>
<BR>
<HR>
</DD>
<DT><B>Block Ciphers</B></DT>
<DD>
<BR>
<HR>
</DD>
<DT><B>Multi-Precision Integer routines</B></DT>
<DD>
<P>The following structure is used to hold a multi-precision integer:
<BR><A NAME="mp32number"></A><PRE><CODE CLASS=c>
typedef struct
{
  uint32  size;
  uint32* data;
} mp32number;
</CODE></PRE>
<P>The following structure is used for barrett modular reduction operations on multi-precision integers:
<BR><A NAME="mp32barrett"></A><PRE><CODE CLASS=c>
typedef struct
{
  uint32  size;
  uint32* modl;
  uint32* mu;
} mp32barrett;
</CODE></PRE>
<BR>
<HR>
</DD>
<DT><B>Discrete Logarithm Public Key Primitives</B></DT>
<DD>
<P>Discrete logarithm operations can be performed in a variety of fields. This API implements discrete logarithms over a prime field, conform with IEEE P1363.
<P>You can find the exact mathematics in:
<BLOCKQUOTE>
<EM>"Handbook of Applied Cryptography"</EM><BR>
Alfred J. Menezes, Paul C. van Oorschot, Scott A. Vanstone<BR>
CRC Press
</BLOCKQUOTE>
<P>The domain parameters are defined by a prime P, a prime factor Q of (P-1), and a group generator G.
<P>The following struct is used to hold the discrete logarithm domain parameters:
<BR><A NAME="dldp_p"></A><PRE><CODE CLASS=c>
typedef struct
{
  <A HREF="#mp32barrett">mp32barrett</A> p;
  <A HREF="#mp32barrett">mp32barrett</A> q;
  <A HREF="#mp32number">mp32number</A>  r;
  <A HREF="#mp32number">mp32number</A>  g;
  <A HREF="#mp32barrett">mp32barrett</A> n;
} dldp_p;
</CODE></PRE>
<P>The struct holds more than the three domain parameters required by IEEE P1363. Some discrete logarithm operations call for a reduction modulo (P-1). Hence we've defined N as (P-1). R is the cofactor of (P-1), so that P-1=N=Q*R, where P and Q are (probable) primes.
<P>If you save the domain parameters, you don't need to save N, and R, since they can be trivially recomputed.
<P>The following functions will operate on this structure:
<DL>
<DT><A NAME="dldp_pInit"></A><CODE CLASS=c>
void <A NAME="dldp_pInit">dldp_pInit</A>(<A HREF="#dldp_p">dldp_p</A>* domain);
</CODE></DT>
<DT><A NAME="dldp_pFree"></A><CODE>
void <A NAME="dldp_pFree">dldp_pFree</A>(<A HREF="#dldp_p">dldp_p</A>* domain);
</CODE></DT>
<DT><A NAME="dldp_pCopy"></A><CODE>
void <A NAME="dldp_pCopy">dldp_pCopy</A>(<A HREF="#dldp_p">dldp_p</A>* dest, const <A HREF="#dldp_p">dldp_p</A>* source);
</CODE></DT>
</DL>
<BR>
<HR>
</DD>
</DL>
</BODY>
</HTML>