X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fengine%2Fhw_openbsd_dev_crypto.c;h=b8aab545db6c85eff74caf83ccd2cf360590a6e0;hp=bf0b8ea16126ef25b767304b9fffd3240b5bd6b8;hb=e88479243cdb19d1bc194f280923395b7856380b;hpb=0d197a833cec53bf34ac21c075a2431ce143eda9 diff --git a/crypto/engine/hw_openbsd_dev_crypto.c b/crypto/engine/hw_openbsd_dev_crypto.c index bf0b8ea161..b8aab545db 100644 --- a/crypto/engine/hw_openbsd_dev_crypto.c +++ b/crypto/engine/hw_openbsd_dev_crypto.c @@ -62,6 +62,7 @@ #else #include "../evp/evp_locl.h" #endif +#include #ifndef OPENSSL_OPENBSD_DEV_CRYPTO @@ -93,14 +94,41 @@ static int dev_crypto_digests(ENGINE *e, const EVP_MD **digest, static const char dev_crypto_id[] = "openbsd_dev_crypto"; static const char dev_crypto_name[] = "OpenBSD /dev/crypto"; +static long allow_misaligned; + +#define DEV_CRYPTO_CMD_ALLOW_MISALIGNED ENGINE_CMD_BASE +static const ENGINE_CMD_DEFN dev_crypto_cmd_defns[]= + { + { DEV_CRYPTO_CMD_ALLOW_MISALIGNED, + "allow_misaligned", + "Permit misaligned data to be used", + ENGINE_CMD_FLAG_NUMERIC }, + { 0, NULL, NULL, 0 } + }; + +static int dev_crypto_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) + { + switch(cmd) + { + case DEV_CRYPTO_CMD_ALLOW_MISALIGNED: + allow_misaligned=i; + printf("allow misaligned=%ld\n",allow_misaligned); + break; + } + + return 1; + } + static ENGINE *engine_openbsd_dev_crypto(void) { ENGINE *engine=ENGINE_new(); if(!ENGINE_set_id(engine, dev_crypto_id) || - !ENGINE_set_name(engine, dev_crypto_name) || - !ENGINE_set_ciphers(engine, dev_crypto_ciphers) || - !ENGINE_set_digests(engine, dev_crypto_digests)) + !ENGINE_set_name(engine, dev_crypto_name) || + !ENGINE_set_ciphers(engine, dev_crypto_ciphers) || + !ENGINE_set_digests(engine, dev_crypto_digests) || + !ENGINE_set_ctrl_function(engine, dev_crypto_ctrl) || + !ENGINE_set_cmd_defns(engine, dev_crypto_cmd_defns)) { ENGINE_free(engine); return NULL; @@ -380,19 +408,19 @@ static int do_digest(int ses,unsigned char *md,const void *data,int len) cryp.op=COP_ENCRYPT;/* required to do the MAC rather than check it */ cryp.len=len; cryp.src=(caddr_t)data; - cryp.dst=(caddr_t)data; // FIXME!!! + cryp.dst=(caddr_t)data; /* FIXME!!! */ cryp.mac=(caddr_t)md; if(ioctl(fd, CIOCCRYPT, &cryp) == -1) { - if(errno == EINVAL) /* buffer is misaligned */ + if(errno == EINVAL && allow_misaligned) /* buffer is misaligned */ { char *dcopy; dcopy=OPENSSL_malloc(len); memcpy(dcopy,data,len); cryp.src=dcopy; - cryp.dst=cryp.src; // FIXME!!! + cryp.dst=cryp.src; /* FIXME!!! */ if(ioctl(fd, CIOCCRYPT, &cryp) == -1) { @@ -409,7 +437,7 @@ static int do_digest(int ses,unsigned char *md,const void *data,int len) return 0; } } - // printf("done\n"); + /* printf("done\n"); */ return 1; } @@ -455,7 +483,7 @@ static int dev_crypto_md5_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from) const MD_DATA *from_md=from->md_data; MD_DATA *to_md=to->md_data; - // How do we copy sessions? + /* How do we copy sessions? */ assert(from->digest->flags&EVP_MD_FLAG_ONESHOT); to_md->data=OPENSSL_malloc(from_md->len); @@ -502,7 +530,7 @@ static const EVP_MD md5_md= NID_md5, NID_md5WithRSAEncryption, MD5_DIGEST_LENGTH, - EVP_MD_FLAG_ONESHOT, // XXX: set according to device info... + EVP_MD_FLAG_ONESHOT, /* XXX: set according to device info... */ dev_crypto_md5_init, dev_crypto_md5_update, dev_crypto_md5_final,