~ubuntu-branches/ubuntu/utopic/dropbear/utopic-proposed

« back to all changes in this revision

Viewing changes to libtomcrypt/sprng.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Johnston
  • Date: 2005-12-08 19:20:21 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208192021-nyp9rwnt77nsg6ty
Tags: 0.47-1
* New upstream release.
* SECURITY: Fix incorrect buffer sizing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
2
 
 *
3
 
 * LibTomCrypt is a library that provides various cryptographic
4
 
 * algorithms in a highly modular and flexible manner.
5
 
 *
6
 
 * The library is free for all purposes without any express
7
 
 * guarantee it works.
8
 
 *
9
 
 * Tom St Denis, tomstdenis@iahu.ca, http://libtomcrypt.org
10
 
 */
11
 
 
12
 
/* A secure PRNG using the RNG functions.  Basically this is a
13
 
 * wrapper that allows you to use a secure RNG as a PRNG
14
 
 * in the various other functions.
15
 
 */
16
 
#include "mycrypt.h"
17
 
 
18
 
#ifdef SPRNG
19
 
 
20
 
const struct _prng_descriptor sprng_desc =
21
 
{
22
 
    "sprng", 0,
23
 
    &sprng_start,
24
 
    &sprng_add_entropy,
25
 
    &sprng_ready,
26
 
    &sprng_read,
27
 
    &sprng_done,
28
 
    &sprng_export,
29
 
    &sprng_import,
30
 
    &sprng_test
31
 
};
32
 
 
33
 
int sprng_start(prng_state *prng)
34
 
{
35
 
   return CRYPT_OK;  
36
 
}
37
 
 
38
 
int sprng_add_entropy(const unsigned char *buf, unsigned long len, prng_state *prng)
39
 
{
40
 
   return CRYPT_OK;
41
 
}
42
 
 
43
 
int sprng_ready(prng_state *prng)
44
 
{
45
 
   return CRYPT_OK;
46
 
}
47
 
 
48
 
unsigned long sprng_read(unsigned char *buf, unsigned long len, prng_state *prng)
49
 
{
50
 
   _ARGCHK(buf != NULL);
51
 
   return rng_get_bytes(buf, len, NULL);
52
 
}
53
 
 
54
 
int sprng_done(prng_state *prng)
55
 
{
56
 
   return CRYPT_OK;
57
 
}
58
 
 
59
 
int sprng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
60
 
{
61
 
   _ARGCHK(outlen != NULL);
62
 
 
63
 
   *outlen = 0;
64
 
   return CRYPT_OK;
65
 
}
66
 
 
67
 
int sprng_import(const unsigned char *in, unsigned long inlen, prng_state *prng)
68
 
{
69
 
   return CRYPT_OK;
70
 
}
71
 
 
72
 
int sprng_test(void)
73
 
{
74
 
   return CRYPT_OK;
75
 
}
76
 
 
77
 
#endif
78
 
 
79
 
 
80