5f5467b0a2579c2ff7cde37662408bdb6ea59c98
3 * The SSL pseudo-random function
5 * (c) 2001 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
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.
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.
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,
28 #ifndef CATACOMB_SSLPRF_H
29 #define CATACOMB_SSLPRF_H
35 /*----- Header files ------------------------------------------------------*/
37 #ifndef CATACOMB_GMAC_H
41 #ifndef CATACOMB_GRAND_H
45 /*----- Data structures ---------------------------------------------------*/
47 typedef 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 */
60 /*----- Functions provided ------------------------------------------------*/
62 /* --- @sslprf_init@ --- *
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
73 * Use: Initializes an SSL generator context.
76 extern 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*/);
81 /* --- @sslprf_encrypt@ --- *
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
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.
97 extern void sslprf_encrypt(sslprf_ctx */
*c*/
,
98 const void */
*src*/
, void */
*dest*/
,
101 /* --- @sslprf_free@ --- *
103 * Arguments: @sslprf_ctx@ = pointer to a context
107 * Use: Frees resources held in an SSL generator context.
110 extern void sslprf_free(sslprf_ctx */
*c*/
);
112 /* ---@sslprf_rand@ --- *
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
120 * Returns: Pointer to generic random number generator interface.
122 * Use: Creates a generic generator which does TLS data expansion.
125 extern grand
*sslprf_rand(const gchash */
*hco*/
, const gchash */
*hci*/
,
126 const void */
*k*/
, size_t /*ksz*/,
127 const void */
*sd*/
, size_t /*sdsz*/);
129 /*----- That's all, folks -------------------------------------------------*/