~ubuntu-branches/ubuntu/trusty/ruby1.9/trusty

« back to all changes in this revision

Viewing changes to ext/openssl/ossl_rand.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2008-01-24 11:42:29 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080124114229-jw2f87rdxlq6gp11
Tags: 1.9.0.0-2ubuntu1
* Merge from debian unstable, remaining changes:
  - Robustify check for target_os, fixing build failure on lpia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: ossl_rand.c 12571 2007-06-18 08:56:21Z technorama $
 
2
 * $Id: ossl_rand.c 14696 2007-12-25 11:31:51Z technorama $
3
3
 * 'OpenSSL for Ruby' project
4
4
 * Copyright (C) 2001-2002  Michal Rokos <m.rokos@sh.cvut.cz>
5
5
 * All rights reserved.
27
27
/*
28
28
 * Private
29
29
 */
 
30
 
 
31
/*
 
32
 *  call-seq:
 
33
 *     seed(str) -> str
 
34
 *
 
35
 */
30
36
static VALUE
31
37
ossl_rand_seed(VALUE self, VALUE str)
32
38
{
38
44
 
39
45
/*
40
46
 *  call-seq:
 
47
 *     add(str, entropy) -> self
 
48
 *
 
49
 */
 
50
static VALUE
 
51
ossl_rand_add(VALUE self, VALUE str, VALUE entropy)
 
52
{
 
53
    StringValue(str);
 
54
    RAND_add(RSTRING_PTR(str), RSTRING_LEN(str), NUM2DBL(entropy));
 
55
 
 
56
    return self;
 
57
}
 
58
 
 
59
/*
 
60
 *  call-seq:
41
61
 *     load_random_file(filename) -> true
42
62
 *
43
63
 */
166
186
    eRandomError = rb_define_class_under(mRandom, "RandomError", eOSSLError);
167
187
        
168
188
    DEFMETH(mRandom, "seed", ossl_rand_seed, 1);
 
189
    DEFMETH(mRandom, "random_add", ossl_rand_add, 2);
169
190
    DEFMETH(mRandom, "load_random_file", ossl_rand_load_file, 1);
170
191
    DEFMETH(mRandom, "write_random_file", ossl_rand_write_file, 1);
171
192
    DEFMETH(mRandom, "random_bytes", ossl_rand_bytes, 1);