From: Nikos Mavrogiannopoulos Date: Sun, 19 Feb 2012 11:21:52 +0000 (+0100) Subject: register the .fast function for cryptodev X-Git-Tag: gnutls_3_0_14~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=11722af465b4e8999d16630067b17ddc64f819ec;p=thirdparty%2Fgnutls.git register the .fast function for cryptodev --- diff --git a/lib/accelerated/cryptodev.c b/lib/accelerated/cryptodev.c index da68474c15..7a34c0c3b6 100644 --- a/lib/accelerated/cryptodev.c +++ b/lib/accelerated/cryptodev.c @@ -360,6 +360,40 @@ cryptodev_mac_output (void *_ctx, void *digest, size_t digestsize) return 0; } +static int +cryptodev_mac_fast (gnutls_mac_algorithm_t algo, + const void *key, size_t key_size, const void *text, + size_t text_size, void *digest) +{ +int mac = gnutls_mac_map[algorithm]; +struct session_op sess; +struct crypt_op cryp; + + sess.mac = mac; + sess.mackey = key; + sess.mackeylen = keysize; + + if (ioctl (cryptodev_fd, CIOCGSESSION, &sess)) + { + gnutls_assert (); + return GNUTLS_E_CRYPTODEV_IOCTL_ERROR; + } + cryp.ses = sess.ses; + cryp.len = text_size; + cryp.src = (void *) text; + cryp.dst = NULL; + cryp.mac = digest; + cryp.op = COP_ENCRYPT; + + if (ioctl (cryptodev_fd, CIOCCRYPT, &cryp)) + { + gnutls_assert (); + return GNUTLS_E_CRYPTODEV_IOCTL_ERROR; + } + + return 0; +} + #define cryptodev_mac_deinit cryptodev_deinit static const gnutls_crypto_mac_st mac_struct = { @@ -368,6 +402,7 @@ static const gnutls_crypto_mac_st mac_struct = { .hash = cryptodev_mac_hash, .output = cryptodev_mac_output, .deinit = cryptodev_mac_deinit + .fast = cryptodev_mac_fast }; static int