summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/demos/maurice
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/src/demos/maurice')
-rw-r--r--src/lib/libssl/src/demos/maurice/Makefile42
-rw-r--r--src/lib/libssl/src/demos/maurice/example1.c14
-rw-r--r--src/lib/libssl/src/demos/maurice/example2.c18
-rw-r--r--src/lib/libssl/src/demos/maurice/example3.c9
-rw-r--r--src/lib/libssl/src/demos/maurice/example4.c7
-rw-r--r--src/lib/libssl/src/demos/maurice/loadkeys.c14
-rw-r--r--src/lib/libssl/src/demos/maurice/loadkeys.h2
7 files changed, 70 insertions, 36 deletions
diff --git a/src/lib/libssl/src/demos/maurice/Makefile b/src/lib/libssl/src/demos/maurice/Makefile
index fa67dcca81..f9bf62276e 100644
--- a/src/lib/libssl/src/demos/maurice/Makefile
+++ b/src/lib/libssl/src/demos/maurice/Makefile
@@ -1,6 +1,6 @@
1CC=cc 1CC=cc
2CFLAGS= -g -I../../include 2CFLAGS= -g -I../../include -Wall
3LIBS= -L/usr/local/ssl/lib -L../.. -lcrypto 3LIBS= -L../.. -lcrypto
4EXAMPLES=example1 example2 example3 example4 4EXAMPLES=example1 example2 example3 example4
5 5
6all: $(EXAMPLES) 6all: $(EXAMPLES)
@@ -17,7 +17,43 @@ example3: example3.o
17example4: example4.o 17example4: example4.o
18 $(CC) -o example4 example4.o $(LIBS) 18 $(CC) -o example4 example4.o $(LIBS)
19 19
20
21clean: 20clean:
22 rm -f $(EXAMPLES) *.o 21 rm -f $(EXAMPLES) *.o
23 22
23test: all
24 @echo
25 @echo Example 1 Demonstrates the sealing and opening APIs
26 @echo Doing the encrypt side...
27 ./example1 <README >t.t
28 @echo Doing the decrypt side...
29 ./example1 -d <t.t >t.2
30 diff t.2 README
31 rm -f t.t t.2
32 @echo example1 is OK
33
34 @echo
35 @echo Example2 Demonstrates rsa encryption and decryption
36 @echo and it should just print \"This the clear text\"
37 ./example2
38
39 @echo
40 @echo Example3 Demonstrates the use of symmetric block ciphers
41 @echo in this case it uses EVP_des_ede3_cbc
42 @echo i.e. triple DES in Cipher Block Chaining mode
43 @echo Doing the encrypt side...
44 ./example3 ThisIsThePassword <README >t.t
45 @echo Doing the decrypt side...
46 ./example3 -d ThisIsThePassword <t.t >t.2
47 diff t.2 README
48 rm -f t.t t.2
49 @echo example3 is OK
50
51 @echo
52 @echo Example4 Demonstrates base64 encoding and decoding
53 @echo Doing the encrypt side...
54 ./example4 <README >t.t
55 @echo Doing the decrypt side...
56 ./example4 -d <t.t >t.2
57 diff t.2 README
58 rm -f t.t t.2
59 @echo example4 is OK
diff --git a/src/lib/libssl/src/demos/maurice/example1.c b/src/lib/libssl/src/demos/maurice/example1.c
index 77730d3232..0e70523a33 100644
--- a/src/lib/libssl/src/demos/maurice/example1.c
+++ b/src/lib/libssl/src/demos/maurice/example1.c
@@ -13,13 +13,13 @@
13#include <strings.h> 13#include <strings.h>
14#include <stdlib.h> 14#include <stdlib.h>
15 15
16#include "rsa.h" 16#include <openssl/rsa.h>
17#include "evp.h" 17#include <openssl/evp.h>
18#include "objects.h" 18#include <openssl/objects.h>
19#include "x509.h" 19#include <openssl/x509.h>
20#include "err.h" 20#include <openssl/err.h>
21#include "pem.h" 21#include <openssl/pem.h>
22#include "ssl.h" 22#include <openssl/ssl.h>
23 23
24#include "loadkeys.h" 24#include "loadkeys.h"
25 25
diff --git a/src/lib/libssl/src/demos/maurice/example2.c b/src/lib/libssl/src/demos/maurice/example2.c
index 99f7b22440..57bce10b5e 100644
--- a/src/lib/libssl/src/demos/maurice/example2.c
+++ b/src/lib/libssl/src/demos/maurice/example2.c
@@ -10,13 +10,13 @@
10#include <stdio.h> 10#include <stdio.h>
11#include <strings.h> 11#include <strings.h>
12 12
13#include "rsa.h" 13#include <openssl/rsa.h>
14#include "evp.h" 14#include <openssl/evp.h>
15#include "objects.h" 15#include <openssl/objects.h>
16#include "x509.h" 16#include <openssl/x509.h>
17#include "err.h" 17#include <openssl/err.h>
18#include "pem.h" 18#include <openssl/pem.h>
19#include "ssl.h" 19#include <openssl/ssl.h>
20 20
21#include "loadkeys.h" 21#include "loadkeys.h"
22 22
@@ -33,7 +33,6 @@ int main()
33 EVP_PKEY *pubKey; 33 EVP_PKEY *pubKey;
34 EVP_PKEY *privKey; 34 EVP_PKEY *privKey;
35 int len; 35 int len;
36 FILE *fp;
37 36
38 ERR_load_crypto_strings(); 37 ERR_load_crypto_strings();
39 38
@@ -72,6 +71,5 @@ int main()
72 EVP_PKEY_free(pubKey); 71 EVP_PKEY_free(pubKey);
73 free(buf); 72 free(buf);
74 free(buf2); 73 free(buf2);
74 return 0;
75} 75}
76
77
diff --git a/src/lib/libssl/src/demos/maurice/example3.c b/src/lib/libssl/src/demos/maurice/example3.c
index fcaff00c37..c8462a47c3 100644
--- a/src/lib/libssl/src/demos/maurice/example3.c
+++ b/src/lib/libssl/src/demos/maurice/example3.c
@@ -8,9 +8,10 @@
8*/ 8*/
9 9
10#include <stdio.h> 10#include <stdio.h>
11#include <unistd.h>
11#include <fcntl.h> 12#include <fcntl.h>
12#include <sys/stat.h> 13#include <sys/stat.h>
13#include <evp.h> 14#include <openssl/evp.h>
14 15
15#define STDIN 0 16#define STDIN 0
16#define STDOUT 1 17#define STDOUT 1
@@ -47,9 +48,9 @@ void do_cipher(char *pw, int operation)
47{ 48{
48 char buf[BUFLEN]; 49 char buf[BUFLEN];
49 char ebuf[BUFLEN + 8]; 50 char ebuf[BUFLEN + 8];
50 unsigned int ebuflen, rc; 51 unsigned int ebuflen; /* rc; */
51 unsigned char iv[EVP_MAX_IV_LENGTH], key[EVP_MAX_KEY_LENGTH]; 52 unsigned char iv[EVP_MAX_IV_LENGTH], key[EVP_MAX_KEY_LENGTH];
52 unsigned int ekeylen, net_ekeylen; 53 /* unsigned int ekeylen, net_ekeylen; */
53 EVP_CIPHER_CTX ectx; 54 EVP_CIPHER_CTX ectx;
54 55
55 memcpy(iv, INIT_VECTOR, sizeof(iv)); 56 memcpy(iv, INIT_VECTOR, sizeof(iv));
@@ -82,5 +83,3 @@ void do_cipher(char *pw, int operation)
82 83
83 write(STDOUT, ebuf, ebuflen); 84 write(STDOUT, ebuf, ebuflen);
84} 85}
85
86
diff --git a/src/lib/libssl/src/demos/maurice/example4.c b/src/lib/libssl/src/demos/maurice/example4.c
index d436a20019..ce629848b7 100644
--- a/src/lib/libssl/src/demos/maurice/example4.c
+++ b/src/lib/libssl/src/demos/maurice/example4.c
@@ -8,9 +8,10 @@
8*/ 8*/
9 9
10#include <stdio.h> 10#include <stdio.h>
11#include <unistd.h>
11#include <fcntl.h> 12#include <fcntl.h>
12#include <sys/stat.h> 13#include <sys/stat.h>
13#include <evp.h> 14#include <openssl/evp.h>
14 15
15#define STDIN 0 16#define STDIN 0
16#define STDOUT 1 17#define STDOUT 1
@@ -44,7 +45,7 @@ void do_encode()
44{ 45{
45 char buf[BUFLEN]; 46 char buf[BUFLEN];
46 char ebuf[BUFLEN+24]; 47 char ebuf[BUFLEN+24];
47 unsigned int ebuflen, rc; 48 unsigned int ebuflen;
48 EVP_ENCODE_CTX ectx; 49 EVP_ENCODE_CTX ectx;
49 50
50 EVP_EncodeInit(&ectx); 51 EVP_EncodeInit(&ectx);
@@ -78,7 +79,7 @@ void do_decode()
78{ 79{
79 char buf[BUFLEN]; 80 char buf[BUFLEN];
80 char ebuf[BUFLEN+24]; 81 char ebuf[BUFLEN+24];
81 unsigned int ebuflen, rc; 82 unsigned int ebuflen;
82 EVP_ENCODE_CTX ectx; 83 EVP_ENCODE_CTX ectx;
83 84
84 EVP_DecodeInit(&ectx); 85 EVP_DecodeInit(&ectx);
diff --git a/src/lib/libssl/src/demos/maurice/loadkeys.c b/src/lib/libssl/src/demos/maurice/loadkeys.c
index 7c89f071f3..0f3464753a 100644
--- a/src/lib/libssl/src/demos/maurice/loadkeys.c
+++ b/src/lib/libssl/src/demos/maurice/loadkeys.c
@@ -14,13 +14,13 @@
14#include <strings.h> 14#include <strings.h>
15#include <stdlib.h> 15#include <stdlib.h>
16 16
17#include "rsa.h" 17#include <openssl/rsa.h>
18#include "evp.h" 18#include <openssl/evp.h>
19#include "objects.h" 19#include <openssl/objects.h>
20#include "x509.h" 20#include <openssl/x509.h>
21#include "err.h" 21#include <openssl/err.h>
22#include "pem.h" 22#include <openssl/pem.h>
23#include "ssl.h" 23#include <openssl/ssl.h>
24 24
25EVP_PKEY * ReadPublicKey(const char *certfile) 25EVP_PKEY * ReadPublicKey(const char *certfile)
26{ 26{
diff --git a/src/lib/libssl/src/demos/maurice/loadkeys.h b/src/lib/libssl/src/demos/maurice/loadkeys.h
index e42c6f8dc4..d8fde86eb7 100644
--- a/src/lib/libssl/src/demos/maurice/loadkeys.h
+++ b/src/lib/libssl/src/demos/maurice/loadkeys.h
@@ -10,7 +10,7 @@
10#ifndef LOADKEYS_H_SEEN 10#ifndef LOADKEYS_H_SEEN
11#define LOADKEYS_H_SEEN 11#define LOADKEYS_H_SEEN
12 12
13#include "evp.h" 13#include <openssl/evp.h>
14 14
15EVP_PKEY * ReadPublicKey(const char *certfile); 15EVP_PKEY * ReadPublicKey(const char *certfile);
16EVP_PKEY *ReadPrivateKey(const char *keyfile); 16EVP_PKEY *ReadPrivateKey(const char *keyfile);