summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src/demos/maurice
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>2002-05-15 02:29:01 +0000
committerbeck <beck@openbsd.org>2002-05-15 02:29:01 +0000
commitda347917d3d3e5d3ece379d298f4e183b4828151 (patch)
tree4667bec6fb5a5191ed165d4bf727adbb97475bcb /lib/libssl/src/demos/maurice
parentOpenSSL 0.9.7 (diff)
downloadwireguard-openbsd-da347917d3d3e5d3ece379d298f4e183b4828151.tar.xz
wireguard-openbsd-da347917d3d3e5d3ece379d298f4e183b4828151.zip
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'lib/libssl/src/demos/maurice')
-rw-r--r--lib/libssl/src/demos/maurice/example1.c8
-rw-r--r--lib/libssl/src/demos/maurice/example3.c6
-rw-r--r--lib/libssl/src/demos/maurice/loadkeys.c9
3 files changed, 9 insertions, 14 deletions
diff --git a/lib/libssl/src/demos/maurice/example1.c b/lib/libssl/src/demos/maurice/example1.c
index 0e70523a336..1ef82999006 100644
--- a/lib/libssl/src/demos/maurice/example1.c
+++ b/lib/libssl/src/demos/maurice/example1.c
@@ -72,7 +72,7 @@ void main_encrypt(void)
pubKey[0] = ReadPublicKey(PUBFILE);
- if(!pubKey)
+ if(!pubKey[0])
{
fprintf(stderr,"Error: can't load public key");
exit(1);
@@ -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/lib/libssl/src/demos/maurice/example3.c b/lib/libssl/src/demos/maurice/example3.c
index c8462a47c37..03d8a20f62b 100644
--- a/lib/libssl/src/demos/maurice/example3.c
+++ b/lib/libssl/src/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/lib/libssl/src/demos/maurice/loadkeys.c b/lib/libssl/src/demos/maurice/loadkeys.c
index 0f3464753af..82fd22a9503 100644
--- a/lib/libssl/src/demos/maurice/loadkeys.c
+++ b/lib/libssl/src/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);
+ 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);
+ pkey = PEM_read_PrivateKey(fp, NULL, 0, NULL);
fclose (fp);