1 diff -Naur openssl-0.9.8u.org/crypto/engine/eng_all.c openssl-0.9.8u/crypto/engine/eng_all.c
2 --- openssl-0.9.8u.org/crypto/engine/eng_all.c 2010-03-01 01:30:11.000000000 +0100
3 +++ openssl-0.9.8u/crypto/engine/eng_all.c 2012-03-27 14:07:11.000000000 +0200
8 -#if defined(__OpenBSD__) || defined(__FreeBSD__)
9 void ENGINE_setup_bsd_cryptodev(void) {
10 static int bsd_cryptodev_default_loaded = 0;
11 if (!bsd_cryptodev_default_loaded) {
14 bsd_cryptodev_default_loaded=1;
17 diff -Naur openssl-0.9.8u.org/crypto/engine/eng_cryptodev.c openssl-0.9.8u/crypto/engine/eng_cryptodev.c
18 --- openssl-0.9.8u.org/crypto/engine/eng_cryptodev.c 2012-03-06 14:22:32.000000000 +0100
19 +++ openssl-0.9.8u/crypto/engine/eng_cryptodev.c 2012-03-27 14:02:59.000000000 +0200
21 * Copyright (c) 2002 Bob Beck <beck@openbsd.org>
22 * Copyright (c) 2002 Theo de Raadt
23 * Copyright (c) 2002 Markus Friedl
24 + * Copyright (c) 2012 Nikos Mavrogiannopoulos
25 * All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
29 #include <openssl/engine.h>
30 #include <openssl/evp.h>
31 #include <openssl/bn.h>
32 -#include <openssl/dsa.h>
33 -#include <openssl/rsa.h>
34 -#include <openssl/dh.h>
35 -#include <openssl/err.h>
37 #if (defined(__unix__) || defined(unix)) && !defined(USG) && \
38 (defined(OpenBSD) || defined(__FreeBSD__))
41 #include <sys/types.h>
42 #include <crypto/cryptodev.h>
43 +#include <crypto/dh/dh.h>
44 +#include <crypto/dsa/dsa.h>
45 +#include <crypto/err/err.h>
46 +#include <crypto/rsa/rsa.h>
47 #include <sys/ioctl.h>
51 struct dev_crypto_state {
52 struct session_op d_sess;
55 +#ifdef USE_CRYPTODEV_DIGESTS
56 + unsigned char digest_res[HASH_MAX_LEN];
62 static u_int32_t cryptodev_asymfeat = 0;
64 static int get_asym_dev_crypto(void);
65 static int open_dev_crypto(void);
66 static int get_dev_crypto(void);
67 -static int cryptodev_max_iv(int cipher);
68 -static int cryptodev_key_length_valid(int cipher, int len);
69 -static int cipher_nid_to_cryptodev(int nid);
70 static int get_cryptodev_ciphers(const int **cnids);
71 -/*static int get_cryptodev_digests(const int **cnids);*/
72 +#ifdef USE_CRYPTODEV_DIGESTS
73 +static int get_cryptodev_digests(const int **cnids);
75 static int cryptodev_usable_ciphers(const int **nids);
76 static int cryptodev_usable_digests(const int **nids);
77 static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
78 - const unsigned char *in, unsigned int inl);
79 + const unsigned char *in, size_t inl);
80 static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
81 const unsigned char *iv, int enc);
82 static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx);
84 static int cryptodev_dh_compute_key(unsigned char *key,
85 const BIGNUM *pub_key, DH *dh);
86 static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
89 void ENGINE_load_cryptodev(void);
91 static const ENGINE_CMD_DEFN cryptodev_defns[] = {
96 + { CRYPTO_ARC4, NID_rc4, 0, 16, },
97 { CRYPTO_DES_CBC, NID_des_cbc, 8, 8, },
98 { CRYPTO_3DES_CBC, NID_des_ede3_cbc, 8, 24, },
99 { CRYPTO_AES_CBC, NID_aes_128_cbc, 16, 16, },
100 + { CRYPTO_AES_CBC, NID_aes_192_cbc, 16, 24, },
101 + { CRYPTO_AES_CBC, NID_aes_256_cbc, 16, 32, },
102 { CRYPTO_BLF_CBC, NID_bf_cbc, 8, 16, },
103 { CRYPTO_CAST_CBC, NID_cast5_cbc, 8, 16, },
104 { CRYPTO_SKIPJACK_CBC, NID_undef, 0, 0, },
105 { 0, NID_undef, 0, 0, },
109 +#ifdef USE_CRYPTODEV_DIGESTS
115 - { CRYPTO_SHA1_HMAC, NID_hmacWithSHA1, },
116 - { CRYPTO_RIPEMD160_HMAC, NID_ripemd160, },
117 - { CRYPTO_MD5_KPDK, NID_undef, },
118 - { CRYPTO_SHA1_KPDK, NID_undef, },
119 - { CRYPTO_MD5, NID_md5, },
120 - { CRYPTO_SHA1, NID_undef, },
123 + /* HMAC is not supported */
124 + { CRYPTO_MD5_HMAC, NID_hmacWithMD5, 16},
125 + { CRYPTO_SHA1_HMAC, NID_hmacWithSHA1, 20},
126 + { CRYPTO_SHA2_256_HMAC, NID_hmacWithSHA256, 32},
127 + { CRYPTO_SHA2_384_HMAC, NID_hmacWithSHA384, 48},
128 + { CRYPTO_SHA2_512_HMAC, NID_hmacWithSHA512, 64},
130 + { CRYPTO_MD5, NID_md5, 16},
131 + { CRYPTO_SHA1, NID_sha1, 20},
132 + { CRYPTO_SHA2_256, NID_sha256, 32},
133 + { CRYPTO_SHA2_384, NID_sha384, 48},
134 + { CRYPTO_SHA2_512, NID_sha512, 64},
135 + { 0, NID_undef, 0},
141 if ((fd = open_dev_crypto()) == -1)
143 +#ifndef CRIOGET_NOT_NEEDED
144 if (ioctl(fd, CRIOGET, &retfd) == -1)
157 +static void put_dev_crypto(int fd)
159 +#ifndef CRIOGET_NOT_NEEDED
164 /* Caching version for asym operations */
166 get_asym_dev_crypto(void)
171 - * XXXX this needs to be set for each alg - and determined from
175 -cryptodev_max_iv(int cipher)
179 - for (i = 0; ciphers[i].id; i++)
180 - if (ciphers[i].id == cipher)
181 - return (ciphers[i].ivmax);
186 - * XXXX this needs to be set for each alg - and determined from
187 - * a running card. For now, fake it out - but most of these
188 - * for real devices should return 1 for the supported key
189 - * sizes the device can handle.
192 -cryptodev_key_length_valid(int cipher, int len)
196 - for (i = 0; ciphers[i].id; i++)
197 - if (ciphers[i].id == cipher)
198 - return (ciphers[i].keylen == len);
202 -/* convert libcrypto nids to cryptodev */
204 -cipher_nid_to_cryptodev(int nid)
208 - for (i = 0; ciphers[i].id; i++)
209 - if (ciphers[i].nid == nid)
210 - return (ciphers[i].id);
215 * Find out what ciphers /dev/crypto will let us have a session for.
216 * XXX note, that some of these openssl doesn't deal with yet!
217 * returning them here is harmless, as long as we return NULL
218 @@ -264,13 +248,14 @@
219 static int nids[CRYPTO_ALGORITHM_MAX];
220 struct session_op sess;
221 int fd, i, count = 0;
222 + unsigned char fake_key[CRYPTO_CIPHER_MAX_KEY_LEN];
224 if ((fd = get_dev_crypto()) < 0) {
228 memset(&sess, 0, sizeof(sess));
229 - sess.key = (caddr_t)"123456781234567812345678";
230 + sess.key = (void*)fake_key;
232 for (i = 0; ciphers[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
233 if (ciphers[i].nid == NID_undef)
235 ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
236 nids[count++] = ciphers[i].nid;
239 + put_dev_crypto(fd);
248 +#ifdef USE_CRYPTODEV_DIGESTS
250 * Find out what digests /dev/crypto will let us have a session for.
251 * XXX note, that some of these openssl doesn't deal with yet!
253 get_cryptodev_digests(const int **cnids)
255 static int nids[CRYPTO_ALGORITHM_MAX];
256 + unsigned char fake_key[CRYPTO_CIPHER_MAX_KEY_LEN];
257 struct session_op sess;
258 int fd, i, count = 0;
260 @@ -310,16 +296,18 @@
263 memset(&sess, 0, sizeof(sess));
264 + sess.mackey = fake_key;
265 for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
266 if (digests[i].nid == NID_undef)
268 sess.mac = digests[i].id;
269 + sess.mackeylen = 8;
271 if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
272 ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
273 nids[count++] = digests[i].nid;
276 + put_dev_crypto(fd);
289 * Find the useable ciphers|digests from dev/crypto - this is the first
292 cryptodev_usable_digests(const int **nids)
294 +#ifdef USE_CRYPTODEV_DIGESTS
295 + return (get_cryptodev_digests(nids));
298 * XXXX just disable all digests for now, because it sucks.
299 * we need a better way to decide this - i.e. I may not
300 @@ -374,11 +364,12 @@
308 cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
309 - const unsigned char *in, unsigned int inl)
310 + const unsigned char *in, size_t inl)
312 struct crypt_op cryp;
313 struct dev_crypto_state *state = ctx->cipher_data;
314 @@ -398,14 +389,14 @@
315 cryp.ses = sess->ses;
318 - cryp.src = (caddr_t) in;
319 - cryp.dst = (caddr_t) out;
320 + cryp.src = (void*) in;
321 + cryp.dst = (void*) out;
324 cryp.op = ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
326 if (ctx->cipher->iv_len) {
327 - cryp.iv = (caddr_t) ctx->iv;
328 + cryp.iv = (void*) ctx->iv;
330 iiv = in + inl - ctx->cipher->iv_len;
331 memcpy(save_iv, iiv, ctx->cipher->iv_len);
332 @@ -436,28 +427,32 @@
334 struct dev_crypto_state *state = ctx->cipher_data;
335 struct session_op *sess = &state->d_sess;
337 + int cipher = -1, i;
339 - if ((cipher = cipher_nid_to_cryptodev(ctx->cipher->nid)) == NID_undef)
342 - if (ctx->cipher->iv_len > cryptodev_max_iv(cipher))
344 + for (i = 0; ciphers[i].id; i++)
345 + if (ctx->cipher->nid == ciphers[i].nid &&
346 + ctx->cipher->iv_len <= ciphers[i].ivmax &&
347 + ctx->key_len == ciphers[i].keylen) {
348 + cipher = ciphers[i].id;
352 - if (!cryptodev_key_length_valid(cipher, ctx->key_len))
353 + if (!ciphers[i].id) {
358 memset(sess, 0, sizeof(struct session_op));
360 if ((state->d_fd = get_dev_crypto()) < 0)
363 - sess->key = (char *)key;
364 + sess->key = (void*)key;
365 sess->keylen = ctx->key_len;
366 sess->cipher = cipher;
368 if (ioctl(state->d_fd, CIOCGSESSION, sess) == -1) {
369 - close(state->d_fd);
370 + put_dev_crypto(state->d_fd);
378 - close(state->d_fd);
379 + put_dev_crypto(state->d_fd);
384 * gets called when libcrypto requests a cipher NID.
388 +const EVP_CIPHER cryptodev_rc4 = {
391 + EVP_CIPH_VARIABLE_LENGTH,
392 + cryptodev_init_key,
395 + sizeof(struct dev_crypto_state),
402 const EVP_CIPHER cryptodev_des_cbc = {
408 +const EVP_CIPHER cryptodev_aes_192_cbc = {
412 + cryptodev_init_key,
415 + sizeof(struct dev_crypto_state),
416 + EVP_CIPHER_set_asn1_iv,
417 + EVP_CIPHER_get_asn1_iv,
421 +const EVP_CIPHER cryptodev_aes_256_cbc = {
425 + cryptodev_init_key,
428 + sizeof(struct dev_crypto_state),
429 + EVP_CIPHER_set_asn1_iv,
430 + EVP_CIPHER_get_asn1_iv,
435 * Registered by the ENGINE when used to find out how to deal with
436 * a particular NID in the ENGINE. this says what we'll do at the
438 return (cryptodev_usable_ciphers(nids));
442 + *cipher = &cryptodev_rc4;
444 case NID_des_ede3_cbc:
445 *cipher = &cryptodev_3des_cbc;
448 case NID_aes_128_cbc:
449 *cipher = &cryptodev_aes_cbc;
451 + case NID_aes_192_cbc:
452 + *cipher = &cryptodev_aes_192_cbc;
454 + case NID_aes_256_cbc:
455 + *cipher = &cryptodev_aes_256_cbc;
460 @@ -607,6 +651,286 @@
461 return (*cipher != NULL);
465 +#ifdef USE_CRYPTODEV_DIGESTS
467 +/* convert digest type to cryptodev */
469 +digest_nid_to_cryptodev(int nid)
473 + for (i = 0; digests[i].id; i++)
474 + if (digests[i].nid == nid)
475 + return (digests[i].id);
480 +static int cryptodev_digest_init(EVP_MD_CTX *ctx)
482 + struct dev_crypto_state *state = ctx->md_data;
483 + struct session_op *sess = &state->d_sess;
486 + if ((digest = digest_nid_to_cryptodev(ctx->digest->type)) == NID_undef){
487 + printf("cryptodev_digest_init: Can't get digest \n");
490 + memset(state, 0, sizeof(struct dev_crypto_state));
492 + if ((state->d_fd = get_dev_crypto()) < 0) {
493 + printf("cryptodev_digest_init: Can't get Dev \n");
497 + sess->mackey = NULL;
498 + sess->mackeylen = 0;
499 + sess->mac = digest;
501 + if (ioctl(state->d_fd, CIOCGSESSION, sess) < 0) {
502 + put_dev_crypto(state->d_fd);
504 + printf("cryptodev_digest_init: Open session failed\n");
511 +static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
514 + struct dev_crypto_state *state = ctx->md_data;
515 + struct crypt_op cryp;
516 + struct session_op *sess = &state->d_sess;
518 + if (!data || state->d_fd < 0) {
519 + printf("cryptodev_digest_update: illegal inputs \n");
527 + if (!(ctx->flags & EVP_MD_CTX_FLAG_ONESHOT)) {
528 + /* if application doesn't support one buffer */
529 + state->mac_data = OPENSSL_realloc(state->mac_data, state->mac_len + count);
531 + if (!state->mac_data) {
532 + printf("cryptodev_digest_update: realloc failed\n");
536 + memcpy(state->mac_data + state->mac_len, data, count);
537 + state->mac_len += count;
542 + memset(&cryp, 0, sizeof(cryp));
544 + cryp.ses = sess->ses;
547 + cryp.src = (void*) data;
549 + cryp.mac = (void*) state->digest_res;
550 + if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
551 + printf("cryptodev_digest_update: digest failed\n");
558 +static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
560 + struct crypt_op cryp;
561 + struct dev_crypto_state *state = ctx->md_data;
562 + struct session_op *sess = &state->d_sess;
564 + if (!md || state->d_fd < 0) {
565 + printf("cryptodev_digest_final: illegal input\n");
569 + if (! (ctx->flags & EVP_MD_CTX_FLAG_ONESHOT) ) {
570 + /* if application doesn't support one buffer */
571 + memset(&cryp, 0, sizeof(cryp));
572 + cryp.ses = sess->ses;
574 + cryp.len = state->mac_len;
575 + cryp.src = state->mac_data;
577 + cryp.mac = (void*)md;
578 + if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
579 + printf("cryptodev_digest_final: digest failed\n");
586 + memcpy(md, state->digest_res, ctx->digest->md_size);
592 +static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
595 + struct dev_crypto_state *state = ctx->md_data;
596 + struct session_op *sess = &state->d_sess;
601 + if (state->d_fd < 0) {
602 + printf("cryptodev_digest_cleanup: illegal input\n");
606 + if (state->mac_data) {
607 + OPENSSL_free(state->mac_data);
608 + state->mac_data = NULL;
609 + state->mac_len = 0;
612 + if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
613 + printf("cryptodev_digest_cleanup: failed to close session\n");
618 + put_dev_crypto(state->d_fd);
624 +static int cryptodev_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
626 + struct dev_crypto_state *fstate = from->md_data;
627 + struct dev_crypto_state *dstate = to->md_data;
628 + struct session_op *sess;
631 + if (dstate == NULL || fstate == NULL)
634 + memcpy(dstate, fstate, sizeof(struct dev_crypto_state));
636 + sess = &dstate->d_sess;
638 + digest = digest_nid_to_cryptodev(to->digest->type);
640 + sess->mackey = NULL;
641 + sess->mackeylen = 0;
642 + sess->mac = digest;
644 + dstate->d_fd = get_dev_crypto();
646 + if (ioctl(dstate->d_fd, CIOCGSESSION, sess) < 0) {
647 + put_dev_crypto(dstate->d_fd);
649 + printf("cryptodev_digest_init: Open session failed\n");
653 + if (fstate->mac_len != 0) {
654 + if (fstate->mac_data != NULL)
656 + dstate->mac_data = OPENSSL_malloc(fstate->mac_len);
657 + memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len);
658 + dstate->mac_len = fstate->mac_len;
666 +static const EVP_MD cryptodev_sha1 = {
668 + NID_sha1WithRSAEncryption,
670 + EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT|EVP_MD_FLAG_ONESHOT,
671 + cryptodev_digest_init,
672 + cryptodev_digest_update,
673 + cryptodev_digest_final,
674 + cryptodev_digest_copy,
675 + cryptodev_digest_cleanup,
676 + EVP_PKEY_RSA_method,
678 + sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
681 +static const EVP_MD cryptodev_sha256 = {
683 + NID_sha256WithRSAEncryption,
684 + SHA256_DIGEST_LENGTH,
685 + EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT|EVP_MD_FLAG_ONESHOT,
686 + cryptodev_digest_init,
687 + cryptodev_digest_update,
688 + cryptodev_digest_final,
689 + cryptodev_digest_copy,
690 + cryptodev_digest_cleanup,
691 + EVP_PKEY_RSA_method,
693 + sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
696 +static const EVP_MD cryptodev_sha384 = {
698 + NID_sha384WithRSAEncryption,
699 + SHA384_DIGEST_LENGTH,
700 + EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT|EVP_MD_FLAG_ONESHOT,
701 + cryptodev_digest_init,
702 + cryptodev_digest_update,
703 + cryptodev_digest_final,
704 + cryptodev_digest_copy,
705 + cryptodev_digest_cleanup,
706 + EVP_PKEY_RSA_method,
708 + sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
711 +static const EVP_MD cryptodev_sha512 = {
713 + NID_sha512WithRSAEncryption,
714 + SHA512_DIGEST_LENGTH,
715 + EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT|EVP_MD_FLAG_ONESHOT,
716 + cryptodev_digest_init,
717 + cryptodev_digest_update,
718 + cryptodev_digest_final,
719 + cryptodev_digest_copy,
720 + cryptodev_digest_cleanup,
721 + EVP_PKEY_RSA_method,
723 + sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
726 +static const EVP_MD cryptodev_md5 = {
728 + NID_md5WithRSAEncryption,
729 + 16 /* MD5_DIGEST_LENGTH */,
730 + EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT|EVP_MD_FLAG_ONESHOT,
731 + cryptodev_digest_init,
732 + cryptodev_digest_update,
733 + cryptodev_digest_final,
734 + cryptodev_digest_copy,
735 + cryptodev_digest_cleanup,
736 + EVP_PKEY_RSA_method,
737 + 64 /* MD5_CBLOCK */,
738 + sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
741 +#endif /* USE_CRYPTODEV_DIGESTS */
745 cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
746 const int **nids, int nid)
747 @@ -615,10 +939,24 @@
748 return (cryptodev_usable_digests(nids));
751 +#ifdef USE_CRYPTODEV_DIGESTS
753 - *digest = NULL; /* need to make a clean md5 critter */
754 + *digest = &cryptodev_md5;
757 + *digest = &cryptodev_sha1;
760 + *digest = &cryptodev_sha256;
763 + *digest = &cryptodev_sha384;
766 + *digest = &cryptodev_sha512;
769 +#endif /* USE_CRYPTODEV_DIGESTS */
777 + memset(b, 0, bytes);
779 - crp->crp_p = (char *)b;
780 + crp->crp_p = (void*) b;
781 crp->crp_nbits = bits;
783 for (i = 0, j = 0; i < a->top; i++) {
788 - for (i = 0; i <= kop->crk_iparams + kop->crk_oparams; i++) {
789 + for (i = 0; i < kop->crk_iparams + kop->crk_oparams; i++) {
790 if (kop->crk_param[i].crp_p)
791 free(kop->crk_param[i].crp_p);
792 kop->crk_param[i].crp_p = NULL;
794 cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
798 + ctx = BN_CTX_new();
799 r = cryptodev_bn_mod_exp(r0, I, rsa->d, rsa->n, ctx, NULL);
805 kop.crk_op = CRK_DSA_SIGN;
807 /* inputs: dgst dsa->p dsa->q dsa->g dsa->priv_key */
808 - kop.crk_param[0].crp_p = (caddr_t)dgst;
809 + kop.crk_param[0].crp_p = (void*)dgst;
810 kop.crk_param[0].crp_nbits = dlen * 8;
811 if (bn2crparam(dsa->p, &kop.crk_param[1]))
814 kop.crk_op = CRK_DSA_VERIFY;
816 /* inputs: dgst dsa->p dsa->q dsa->g dsa->pub_key sig->r sig->s */
817 - kop.crk_param[0].crp_p = (caddr_t)dgst;
818 + kop.crk_param[0].crp_p = (void*)dgst;
819 kop.crk_param[0].crp_nbits = dlen * 8;
820 if (bn2crparam(dsa->p, &kop.crk_param[1]))
822 @@ -1017,7 +1357,7 @@
826 - kop.crk_param[3].crp_p = (char *)key;
827 + kop.crk_param[3].crp_p = (void*) key;
828 kop.crk_param[3].crp_nbits = keylen * 8;
831 @@ -1048,7 +1388,7 @@
832 * but I expect we'll want some options soon.
835 -cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
836 +cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
839 struct syslog_data sd = SYSLOG_DATA_INIT;
840 @@ -1084,14 +1424,14 @@
841 * find out what asymmetric crypto algorithms we support
843 if (ioctl(fd, CIOCASYMFEAT, &cryptodev_asymfeat) == -1) {
845 + put_dev_crypto(fd);
850 + put_dev_crypto(fd);
852 if (!ENGINE_set_id(engine, "cryptodev") ||
853 - !ENGINE_set_name(engine, "BSD cryptodev engine") ||
854 + !ENGINE_set_name(engine, "cryptodev engine") ||
855 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
856 !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
857 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
858 diff -Naur openssl-0.9.8u.org/crypto/engine/engine.h openssl-0.9.8u/crypto/engine/engine.h
859 --- openssl-0.9.8u.org/crypto/engine/engine.h 2010-02-09 15:18:15.000000000 +0100
860 +++ openssl-0.9.8u/crypto/engine/engine.h 2012-03-27 14:05:15.000000000 +0200
863 void *ENGINE_get_static_state(void);
865 -#if defined(__OpenBSD__) || defined(__FreeBSD__)
866 void ENGINE_setup_bsd_cryptodev(void);
869 /* BEGIN ERROR CODES */
870 /* The following lines are auto generated by the script mkerr.pl. Any changes
871 diff -Naur openssl-0.9.8u.org/crypto/evp/c_all.c openssl-0.9.8u/crypto/evp/c_all.c
872 --- openssl-0.9.8u.org/crypto/evp/c_all.c 2004-08-29 18:36:04.000000000 +0200
873 +++ openssl-0.9.8u/crypto/evp/c_all.c 2012-03-27 14:05:15.000000000 +0200
875 OpenSSL_add_all_ciphers();
876 OpenSSL_add_all_digests();
877 #ifndef OPENSSL_NO_ENGINE
878 -# if defined(__OpenBSD__) || defined(__FreeBSD__)
879 ENGINE_setup_bsd_cryptodev();