Delete extra ;
[oweals/openssl.git] / crypto / evp / evp_key.c
index 667c21cca8d365f9c594347f985a3ef806c54edb..91738a273f33d3b40cede694f6f5e1be11dae4d4 100644 (file)
@@ -61,6 +61,7 @@
 #include <openssl/x509.h>
 #include <openssl/objects.h>
 #include <openssl/evp.h>
+#include <openssl/ui.h>
 
 /* should be init to zeros. */
 static char prompt_string[80];
@@ -86,18 +87,26 @@ char *EVP_get_pw_prompt(void)
  * this function will fail */
 int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
        {
-#ifndef NO_DES
+       int ret;
+       char buff[BUFSIZ];
+       UI *ui;
+
        if ((prompt == NULL) && (prompt_string[0] != '\0'))
                prompt=prompt_string;
-       return(des_read_pw_string(buf,len,prompt,verify));
-#else
-       return -1;
-#endif
+       ui = UI_new();
+       UI_add_input_string(ui,prompt,0,buf,0,(len>=BUFSIZ)?BUFSIZ-1:len);
+       if (verify)
+               UI_add_verify_string(ui,prompt,0,
+                       buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf);
+       ret = UI_process(ui);
+       UI_free(ui);
+       memset(buff,0,BUFSIZ);
+       return ret;
        }
 
-int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, unsigned char *salt,
-            unsigned char *data, int datal, int count, unsigned char *key,
-            unsigned char *iv)
+int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, 
+            const unsigned char *salt, const unsigned char *data, int datal,
+            int count, unsigned char *key, unsigned char *iv)
        {
        EVP_MD_CTX c;
        unsigned char md_buf[EVP_MAX_MD_SIZE];
@@ -116,7 +125,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, unsigned char *salt,
                        EVP_DigestUpdate(&c,&(md_buf[0]),mds);
                EVP_DigestUpdate(&c,data,datal);
                if (salt != NULL)
-                       EVP_DigestUpdate(&c,salt,8);
+                       EVP_DigestUpdate(&c,salt,PKCS5_SALT_LEN);
                EVP_DigestFinal(&c,&(md_buf[0]),&mds);
 
                for (i=1; i<(unsigned int)count; i++)