summaryrefslogtreecommitdiffstats
path: root/crypto/openssl/demos/maurice
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/demos/maurice')
-rw-r--r--crypto/openssl/demos/maurice/example1.c6
-rw-r--r--crypto/openssl/demos/maurice/example3.c6
-rw-r--r--crypto/openssl/demos/maurice/loadkeys.c9
3 files changed, 8 insertions, 13 deletions
diff --git a/crypto/openssl/demos/maurice/example1.c b/crypto/openssl/demos/maurice/example1.c
index 52152704..1ef8299 100644
--- a/crypto/openssl/demos/maurice/example1.c
+++ b/crypto/openssl/demos/maurice/example1.c
@@ -126,11 +126,11 @@ void main_encrypt(void)
void main_decrypt(void)
{
- char buf[512];
+ char buf[520];
char ebuf[512];
unsigned int buflen;
EVP_CIPHER_CTX ectx;
- unsigned char iv[8];
+ unsigned char iv[EVP_MAX_IV_LENGTH];
unsigned char *encryptKey;
unsigned int ekeylen;
EVP_PKEY *privateKey;
@@ -164,7 +164,6 @@ void main_decrypt(void)
read(STDIN, encryptKey, ekeylen);
read(STDIN, iv, sizeof(iv));
-
EVP_OpenInit(&ectx,
EVP_des_ede3_cbc(),
encryptKey,
@@ -185,7 +184,6 @@ void main_decrypt(void)
}
EVP_OpenUpdate(&ectx, buf, &buflen, ebuf, readlen);
-
write(STDOUT, buf, buflen);
}
diff --git a/crypto/openssl/demos/maurice/example3.c b/crypto/openssl/demos/maurice/example3.c
index c8462a4..03d8a20 100644
--- a/crypto/openssl/demos/maurice/example3.c
+++ b/crypto/openssl/demos/maurice/example3.c
@@ -57,7 +57,8 @@ void do_cipher(char *pw, int operation)
EVP_BytesToKey(ALG, EVP_md5(), "salu", pw, strlen(pw), 1, key, iv);
- EVP_CipherInit(&ectx, ALG, key, iv, operation);
+ EVP_CIPHER_CTX_init(&ectx);
+ EVP_CipherInit_ex(&ectx, ALG, NULL, key, iv, operation);
while(1)
{
@@ -79,7 +80,8 @@ void do_cipher(char *pw, int operation)
write(STDOUT, ebuf, ebuflen);
}
- EVP_CipherFinal(&ectx, ebuf, &ebuflen);
+ EVP_CipherFinal_ex(&ectx, ebuf, &ebuflen);
+ EVP_CIPHER_CTX_cleanup(&ectx);
write(STDOUT, ebuf, ebuflen);
}
diff --git a/crypto/openssl/demos/maurice/loadkeys.c b/crypto/openssl/demos/maurice/loadkeys.c
index 792371c..82fd22a 100644
--- a/crypto/openssl/demos/maurice/loadkeys.c
+++ b/crypto/openssl/demos/maurice/loadkeys.c
@@ -31,9 +31,7 @@ EVP_PKEY * ReadPublicKey(const char *certfile)
if (!fp)
return NULL;
- x509 = (X509 *)PEM_ASN1_read ((char *(*)())d2i_X509,
- PEM_STRING_X509,
- fp, NULL, NULL, NULL);
+ x509 = PEM_read_X509(fp, NULL, 0, NULL);
if (x509 == NULL)
{
@@ -61,10 +59,7 @@ EVP_PKEY *ReadPrivateKey(const char *keyfile)
if (!fp)
return NULL;
- pkey = (EVP_PKEY*)PEM_ASN1_read ((char *(*)())d2i_PrivateKey,
- PEM_STRING_EVP_PKEY,
- fp,
- NULL, NULL, NULL);
+ pkey = PEM_read_PrivateKey(fp, NULL, 0, NULL);
fclose (fp);
OpenPOWER on IntegriCloud