aboutsummaryrefslogtreecommitdiff
path: root/crypto/pem
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>1999-12-24 23:53:57 +0000
committerDr. Stephen Henson <steve@openssl.org>1999-12-24 23:53:57 +0000
commit36217a942488852b616974e168a6ff0fecfb02fa (patch)
tree416a573e7d641b0209f7479c93070cc5365de039 /crypto/pem
parent12aefe78f0aec57159e396b5fd8f71644a76b631 (diff)
downloadopenssl-36217a942488852b616974e168a6ff0fecfb02fa.zip
openssl-36217a942488852b616974e168a6ff0fecfb02fa.tar.gz
openssl-36217a942488852b616974e168a6ff0fecfb02fa.tar.bz2
Allow passwords to be included on command line for a few
more utilities.
Diffstat (limited to 'crypto/pem')
-rw-r--r--crypto/pem/pem.h3
-rw-r--r--crypto/pem/pem_lib.c16
2 files changed, 19 insertions, 0 deletions
diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h
index 26c313b..80ab491 100644
--- a/crypto/pem/pem.h
+++ b/crypto/pem/pem.h
@@ -601,6 +601,9 @@ EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, vo
int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
char *kstr,int klen, pem_password_cb *cd, void *u);
+#ifdef MS_CALLBACK
+int MS_CALLBACK PEM_cb(char *buf, int len, int verify, void *key);
+#endif
#endif /* SSLEAY_MACROS */
diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c
index 2bafb5e..bb2597b 100644
--- a/crypto/pem/pem_lib.c
+++ b/crypto/pem/pem_lib.c
@@ -121,6 +121,22 @@ static int def_callback(char *buf, int num, int w, void *userdata)
#endif
}
+/* This is a generic callback. If the user data is not NULL it is assumed
+ * to be a null terminated password. Otherwise the default password callback
+ * is called.
+ */
+
+
+int MS_CALLBACK PEM_cb(char *buf, int len, int verify, void *key)
+{
+ int i;
+ if (key == NULL) return def_callback(buf, len, verify, key);
+ i=strlen(key);
+ i=(i > len)?len:i;
+ memcpy(buf,key,i);
+ return(i);
+}
+
void PEM_proc_type(char *buf, int type)
{
const char *str;