3 * $Id: sslprf.h,v 1.1 2001/04/06 22:05:10 mdw Exp $
5 * The SSL pseudo-random function
7 * (c) 2001 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.1 2001/04/06 22:05:10 mdw
34 * Add support for SSL pseudo-random function.
38 #ifndef CATACOMB_SSLPRF_H
39 #define CATACOMB_SSLPRF_H
45 /*----- Header files ------------------------------------------------------*/
47 #ifndef CATACOMB_GMAC_H
51 #ifndef CATACOMB_GRAND_H
55 /*----- Data structures ---------------------------------------------------*/
57 typedef struct sslprf_ctx {
58 const gchash *co, *ci; /* Outer and inner hash functions */
59 size_t ohashsz, ihashsz; /* Size of the hash outputs */
60 ghash *h; /* Hash context from last time */
61 const octet *k; /* Pointer to the secret */
62 size_t ksz; /* Size of the secret buffer */
63 const octet *sd; /* Pointer to the seed */
64 size_t sdsz; /* Size of the seed buffer */
65 unsigned i; /* Which iteration this is */
66 octet *p; /* Pointer to output buffer */
67 size_t sz; /* How many bytes are left */
70 /*----- Functions provided ------------------------------------------------*/
72 /* --- @sslprf_init@ --- *
74 * Arguments: @sslprf_ctx *c@ = pointer to a context structure
75 * @const gchash *hco, *hci@ = outer and inner hash functions
76 * @const void *k@ = pointer to secret buffer
77 * @size_t ksz@ = size of the secret
78 * @const void *sd@ = pointer to seed buffer
79 * @size_t sdsz@ = size of the seed
83 * Use: Initializes an SSL generator context.
86 extern void sslprf_init(sslprf_ctx */*c*/,
87 const gchash */*hco*/, const gchash */*hci*/,
88 const void */*k*/, size_t /*ksz*/,
89 const void */*sd*/, size_t /*sdsz*/);
91 /* --- @sslprf_encrypt@ --- *
93 * Arguments: @sslprf_ctx *c@ = pointer to a context structure
94 * @const void *src@ = pointer to source buffer
95 * @void *dest@ = pointer to destination buffer
96 * @size_t sz@ = size of the buffers
100 * Use: Encrypts data using the SSL pseudo-random function. If the
101 * destination pointer is null, the generator is spun and no
102 * output is produced; if the source pointer is null, raw output
103 * from the generator is written; otherwise, the source data is
104 * XORed with the generator output.
107 extern void sslprf_encrypt(sslprf_ctx */*c*/,
108 const void */*src*/, void */*dest*/,
111 /* --- @sslprf_free@ --- *
113 * Arguments: @sslprf_ctx@ = pointer to a context
117 * Use: Frees resources held in an SSL generator context.
120 extern void sslprf_free(sslprf_ctx */*c*/);
122 /* ---@sslprf_rand@ --- *
124 * Arguments: @const gchash *hco, const gchash *hci@ = hash functions
125 * @const void *k@ = pointer to the key material
126 * @size_t ksz@ = size of the key material
127 * @const void *sd@ = pointer to the seed material
128 * @size_t sdsz@ = size of the seed material
130 * Returns: Pointer to generic random number generator interface.
132 * Use: Creates a generic generator which does TLS data expansion.
135 extern grand *sslprf_rand(const gchash */*hco*/, const gchash */*hci*/,
136 const void */*k*/, size_t /*ksz*/,
137 const void */*sd*/, size_t /*sdsz*/);
139 /*----- That's all, folks -------------------------------------------------*/