Commit 98fea0551802cc58ded84f8be26a7d7ddafe845a
rename copied functions with ruby prefix so they don't conflict with
native versions where available. Signed-off-by: Aman Gupta <aman@tmm1.net>Ted Unangst authored on 12/16/2010, 6:33:59 AM
Aman Gupta committed on 12/20/2010, 6:58:43 PM
Parent: 32a206ce672a8af55442c22e030e147da01ddde3
Files changed
ext/mri/bcrypt.c | changed |
ext/mri/bcrypt.h | changed |
ext/mri/bcrypt_ext.c | changed |
ext/mri/bcrypt.c | ||
---|---|---|
@@ -149,9 +149,9 @@ | ||
149 | 149 | seems sensible. |
150 | 150 | */ |
151 | 151 | |
152 | 152 | char * |
153 | -bcrypt_gensalt(char *output, uint8_t log_rounds, uint8_t *rseed) | |
153 | +ruby_bcrypt_gensalt(char *output, uint8_t log_rounds, uint8_t *rseed) | |
154 | 154 | { |
155 | 155 | if (log_rounds < 4) |
156 | 156 | log_rounds = 4; |
157 | 157 | else if (log_rounds > 31) |
@@ -163,9 +163,9 @@ | ||
163 | 163 | /* We handle $Vers$log2(NumRounds)$salt+passwd$ |
164 | 164 | i.e. $2$04$iwouldntknowwhattosayetKdJ6iFtacBqJdKe6aW7ou */ |
165 | 165 | |
166 | 166 | char * |
167 | -bcrypt(char *output, const char *key, const char *salt) | |
167 | +ruby_bcrypt(char *output, const char *key, const char *salt) | |
168 | 168 | { |
169 | 169 | blf_ctx state; |
170 | 170 | uint32_t rounds, i, k; |
171 | 171 | uint16_t j; |
ext/mri/bcrypt.h | ||
---|---|---|
@@ -50,9 +50,9 @@ | ||
50 | 50 | * rseed: a seed of BCRYPT_MAXSALT bytes. Should be obtained from a |
51 | 51 | * cryptographically secure random source. |
52 | 52 | * Returns: output |
53 | 53 | */ |
54 | -char *bcrypt_gensalt(char *output, uint8_t log_rounds, uint8_t *rseed); | |
54 | +char *ruby_bcrypt_gensalt(char *output, uint8_t log_rounds, uint8_t *rseed); | |
55 | 55 | |
56 | 56 | /* |
57 | 57 | * Given a secret and a salt, generates a salted hash (which you can then store safely). |
58 | 58 | * |
@@ -61,7 +61,7 @@ | ||
61 | 61 | * key: A null-terminated secret. |
62 | 62 | * salt: The salt, as generated by bcrypt_gensalt(). |
63 | 63 | * Returns: output on success, NULL on error. |
64 | 64 | */ |
65 | -char *bcrypt(char *output, const char *key, const char *salt); | |
65 | +char *ruby_bcrypt(char *output, const char *key, const char *salt); | |
66 | 66 | |
67 | 67 |
ext/mri/bcrypt_ext.c | ||
---|---|---|
@@ -29,9 +29,9 @@ | ||
29 | 29 | } BCryptArguments; |
30 | 30 | |
31 | 31 | static VALUE bcrypt_wrapper(void *_args) { |
32 | 32 | BCryptArguments *args = (BCryptArguments *)_args; |
33 | - return (VALUE)bcrypt(args->output, args->key, args->salt); | |
33 | + return (VALUE)ruby_bcrypt(args->output, args->key, args->salt); | |
34 | 34 | } |
35 | 35 | |
36 | 36 | |
37 | 37 | |
@@ -40,9 +40,9 @@ | ||
40 | 40 | static VALUE bc_salt(VALUE self, VALUE cost, VALUE seed) { |
41 | 41 | int icost = NUM2INT(cost); |
42 | 42 | char salt[BCRYPT_SALT_OUTPUT_SIZE]; |
43 | 43 | |
44 | - bcrypt_gensalt(salt, icost, (uint8_t *)RSTRING_PTR(seed)); | |
44 | + ruby_bcrypt_gensalt(salt, icost, (uint8_t *)RSTRING_PTR(seed)); | |
45 | 45 | return rb_str_new2(salt); |
46 | 46 | } |
47 | 47 | |
48 | 48 | /* Given a secret and a salt, generates a salted hash (which you can then store safely). |
@@ -69,9 +69,9 @@ | ||
69 | 69 | } |
70 | 70 | /* otherwise, fallback to the non-GIL-unlocking code, just like on Ruby 1.8 */ |
71 | 71 | |
72 | 72 | |
73 | - if (bcrypt(output, safeguarded, (char *)RSTRING_PTR(salt)) != NULL) { | |
73 | + if (ruby_bcrypt(output, safeguarded, (char *)RSTRING_PTR(salt)) != NULL) { | |
74 | 74 | return rb_str_new2(output); |
75 | 75 | } else { |
76 | 76 | return Qnil; |
77 | 77 | } |
Built with git-ssb-web