Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: srtp/crypto/include/prng.h

Issue 2344973002: Update libsrtp to version 2.0 (Closed)
Patch Set: Add '.' back to include_dirs Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « srtp/crypto/include/null_cipher.h ('k') | srtp/crypto/include/rand_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * prng.h
3 *
4 * pseudorandom source
5 *
6 * David A. McGrew
7 * Cisco Systems, Inc.
8 */
9
10 /*
11 *
12 * Copyright (c) 2001-2006, Cisco Systems, Inc.
13 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
19 * Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
22 * Redistributions in binary form must reproduce the above
23 * copyright notice, this list of conditions and the following
24 * disclaimer in the documentation and/or other materials provided
25 * with the distribution.
26 *
27 * Neither the name of the Cisco Systems, Inc. nor the names of its
28 * contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
42 * OF THE POSSIBILITY OF SUCH DAMAGE.
43 *
44 */
45
46 #ifndef PRNG_H
47 #define PRNG_H
48
49 #include "rand_source.h" /* for rand_source_func_t definition */
50 #include "aes.h" /* for aes */
51 //FIXME: this is temporary until we pull in the code to use OpenSSL for RNG
52 #ifdef OPENSSL
53 #include "aes_icm_ossl.h" /* for aes ctr */
54 #else
55 #include "aes_icm.h" /* for aes ctr */
56 #endif
57
58 #define MAX_PRNG_OUT_LEN 0xffffffffU
59
60 /*
61 * x917_prng is an ANSI X9.17-like AES-based PRNG
62 */
63
64 typedef struct {
65 v128_t state; /* state data */
66 aes_expanded_key_t key; /* secret key */
67 uint32_t octet_count; /* number of octets output since last init */
68 rand_source_func_t rand; /* random source for re-initialization */
69 } x917_prng_t;
70
71 err_status_t
72 x917_prng_init(rand_source_func_t random_source);
73
74 err_status_t
75 x917_prng_get_octet_string(uint8_t *dest, uint32_t len);
76
77
78 /*
79 * ctr_prng is an AES-CTR based PRNG
80 */
81
82 typedef struct {
83 uint32_t octet_count; /* number of octets output since last init */
84 aes_icm_ctx_t state; /* state data */
85 rand_source_func_t rand; /* random source for re-initialization */
86 } ctr_prng_t;
87
88 err_status_t
89 ctr_prng_init(rand_source_func_t random_source);
90
91 err_status_t
92 ctr_prng_get_octet_string(void *dest, uint32_t len);
93
94
95 #endif
OLDNEW
« no previous file with comments | « srtp/crypto/include/null_cipher.h ('k') | srtp/crypto/include/rand_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698