| OLD | NEW |
| 1 /* crypto/evp/evp_key.c */ | 1 /* crypto/evp/evp_key.c */ |
| 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
| 6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
| 7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
| 8 * | 8 * |
| 9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
| 10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return(NULL); | 83 return(NULL); |
| 84 else | 84 else |
| 85 return(prompt_string); | 85 return(prompt_string); |
| 86 } | 86 } |
| 87 | 87 |
| 88 /* For historical reasons, the standard function for reading passwords is | 88 /* For historical reasons, the standard function for reading passwords is |
| 89 * in the DES library -- if someone ever wants to disable DES, | 89 * in the DES library -- if someone ever wants to disable DES, |
| 90 * this function will fail */ | 90 * this function will fail */ |
| 91 int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) | 91 int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) |
| 92 { | 92 { |
| 93 return EVP_read_pw_string_min(buf, 0, len, prompt, verify); |
| 94 } |
| 95 |
| 96 int EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt, int
verify) |
| 97 { |
| 93 int ret; | 98 int ret; |
| 94 char buff[BUFSIZ]; | 99 char buff[BUFSIZ]; |
| 95 UI *ui; | 100 UI *ui; |
| 96 | 101 |
| 97 if ((prompt == NULL) && (prompt_string[0] != '\0')) | 102 if ((prompt == NULL) && (prompt_string[0] != '\0')) |
| 98 prompt=prompt_string; | 103 prompt=prompt_string; |
| 99 ui = UI_new(); | 104 ui = UI_new(); |
| 100 » UI_add_input_string(ui,prompt,0,buf,0,(len>=BUFSIZ)?BUFSIZ-1:len); | 105 » UI_add_input_string(ui,prompt,0,buf,min,(len>=BUFSIZ)?BUFSIZ-1:len); |
| 101 if (verify) | 106 if (verify) |
| 102 UI_add_verify_string(ui,prompt,0, | 107 UI_add_verify_string(ui,prompt,0, |
| 103 » » » buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf); | 108 » » » buff,min,(len>=BUFSIZ)?BUFSIZ-1:len,buf); |
| 104 ret = UI_process(ui); | 109 ret = UI_process(ui); |
| 105 UI_free(ui); | 110 UI_free(ui); |
| 106 OPENSSL_cleanse(buff,BUFSIZ); | 111 OPENSSL_cleanse(buff,BUFSIZ); |
| 107 return ret; | 112 return ret; |
| 108 } | 113 } |
| 109 | 114 |
| 110 int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, | 115 int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, |
| 111 const unsigned char *salt, const unsigned char *data, int datal, | 116 const unsigned char *salt, const unsigned char *data, int datal, |
| 112 int count, unsigned char *key, unsigned char *iv) | 117 int count, unsigned char *key, unsigned char *iv) |
| 113 { | 118 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 i++; | 171 i++; |
| 167 } | 172 } |
| 168 } | 173 } |
| 169 if ((nkey == 0) && (niv == 0)) break; | 174 if ((nkey == 0) && (niv == 0)) break; |
| 170 } | 175 } |
| 171 EVP_MD_CTX_cleanup(&c); | 176 EVP_MD_CTX_cleanup(&c); |
| 172 OPENSSL_cleanse(&(md_buf[0]),EVP_MAX_MD_SIZE); | 177 OPENSSL_cleanse(&(md_buf[0]),EVP_MAX_MD_SIZE); |
| 173 return(type->key_len); | 178 return(type->key_len); |
| 174 } | 179 } |
| 175 | 180 |
| OLD | NEW |