math/mpreduce.h: Missing include files.
[u/mdw/catacomb] / rand / sslprf.h
CommitLineData
51a0f805 1/* -*-c-*-
2 *
51a0f805 3 * The SSL pseudo-random function
4 *
5 * (c) 2001 Straylight/Edgeware
6 */
7
45c0fd36 8/*----- Licensing notice --------------------------------------------------*
51a0f805 9 *
10 * This file is part of Catacomb.
11 *
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
45c0fd36 16 *
51a0f805 17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
45c0fd36 21 *
51a0f805 22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * MA 02111-1307, USA.
26 */
27
51a0f805 28#ifndef CATACOMB_SSLPRF_H
29#define CATACOMB_SSLPRF_H
30
31#ifdef __cplusplus
32 extern "C" {
33#endif
34
35/*----- Header files ------------------------------------------------------*/
36
37#ifndef CATACOMB_GMAC_H
38# include "gmac.h"
39#endif
40
41#ifndef CATACOMB_GRAND_H
42# include "grand.h"
43#endif
44
45/*----- Data structures ---------------------------------------------------*/
46
47typedef struct sslprf_ctx {
48 const gchash *co, *ci; /* Outer and inner hash functions */
49 size_t ohashsz, ihashsz; /* Size of the hash outputs */
50 ghash *h; /* Hash context from last time */
51 const octet *k; /* Pointer to the secret */
52 size_t ksz; /* Size of the secret buffer */
53 const octet *sd; /* Pointer to the seed */
54 size_t sdsz; /* Size of the seed buffer */
55 unsigned i; /* Which iteration this is */
56 octet *p; /* Pointer to output buffer */
57 size_t sz; /* How many bytes are left */
58} sslprf_ctx;
59
60/*----- Functions provided ------------------------------------------------*/
61
62/* --- @sslprf_init@ --- *
63 *
64 * Arguments: @sslprf_ctx *c@ = pointer to a context structure
65 * @const gchash *hco, *hci@ = outer and inner hash functions
66 * @const void *k@ = pointer to secret buffer
67 * @size_t ksz@ = size of the secret
68 * @const void *sd@ = pointer to seed buffer
69 * @size_t sdsz@ = size of the seed
70 *
71 * Returns: ---
72 *
73 * Use: Initializes an SSL generator context.
74 */
75
76extern void sslprf_init(sslprf_ctx */*c*/,
77 const gchash */*hco*/, const gchash */*hci*/,
78 const void */*k*/, size_t /*ksz*/,
79 const void */*sd*/, size_t /*sdsz*/);
80
81/* --- @sslprf_encrypt@ --- *
82 *
83 * Arguments: @sslprf_ctx *c@ = pointer to a context structure
84 * @const void *src@ = pointer to source buffer
85 * @void *dest@ = pointer to destination buffer
86 * @size_t sz@ = size of the buffers
87 *
88 * Returns: ---
89 *
90 * Use: Encrypts data using the SSL pseudo-random function. If the
91 * destination pointer is null, the generator is spun and no
92 * output is produced; if the source pointer is null, raw output
93 * from the generator is written; otherwise, the source data is
94 * XORed with the generator output.
95 */
96
97extern void sslprf_encrypt(sslprf_ctx */*c*/,
98 const void */*src*/, void */*dest*/,
99 size_t /*sz*/);
100
101/* --- @sslprf_free@ --- *
102 *
103 * Arguments: @sslprf_ctx@ = pointer to a context
104 *
105 * Returns: ---
106 *
107 * Use: Frees resources held in an SSL generator context.
108 */
109
110extern void sslprf_free(sslprf_ctx */*c*/);
111
112/* ---@sslprf_rand@ --- *
113 *
114 * Arguments: @const gchash *hco, const gchash *hci@ = hash functions
115 * @const void *k@ = pointer to the key material
116 * @size_t ksz@ = size of the key material
117 * @const void *sd@ = pointer to the seed material
118 * @size_t sdsz@ = size of the seed material
119 *
120 * Returns: Pointer to generic random number generator interface.
121 *
122 * Use: Creates a generic generator which does TLS data expansion.
123 */
124
125extern grand *sslprf_rand(const gchash */*hco*/, const gchash */*hci*/,
126 const void */*k*/, size_t /*ksz*/,
127 const void */*sd*/, size_t /*sdsz*/);
128
129/*----- That's all, folks -------------------------------------------------*/
130
131#ifdef __cplusplus
132 }
133#endif
134
135#endif