Blame lib/accelerated/cryptodev.c

Packit aea12f
/*
Packit aea12f
 * Copyright (C) 2009-2010, 2012 Free Software Foundation, Inc.
Packit aea12f
 *
Packit aea12f
 * Author: Nikos Mavrogiannopoulos
Packit aea12f
 *
Packit aea12f
 * This file is part of GnuTLS.
Packit aea12f
 *
Packit aea12f
 * The GnuTLS is free software; you can redistribute it and/or
Packit aea12f
 * modify it under the terms of the GNU Lesser General Public License
Packit aea12f
 * as published by the Free Software Foundation; either version 2.1 of
Packit aea12f
 * the License, or (at your option) any later version.
Packit aea12f
 *
Packit aea12f
 * This library is distributed in the hope that it will be useful, but
Packit aea12f
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit aea12f
 * Lesser General Public License for more details.
Packit aea12f
 *
Packit aea12f
 * You should have received a copy of the GNU Lesser General Public License
Packit aea12f
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
Packit aea12f
 *
Packit aea12f
 */
Packit aea12f
Packit aea12f
#include "errors.h"
Packit aea12f
#include "gnutls_int.h"
Packit aea12f
#include <gnutls/crypto.h>
Packit aea12f
#include "errors.h"
Packit aea12f
#include <accelerated/cryptodev.h>
Packit aea12f
Packit aea12f
#ifdef ENABLE_CRYPTODEV
Packit aea12f
Packit aea12f
#include <assert.h>
Packit aea12f
#include <fcntl.h>
Packit aea12f
#include <sys/ioctl.h>
Packit aea12f
#include <crypto/cryptodev.h>
Packit aea12f
Packit aea12f
#ifndef CRYPTO_CIPHER_MAX_KEY_LEN
Packit aea12f
#define CRYPTO_CIPHER_MAX_KEY_LEN 64
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#ifndef EALG_MAX_BLOCK_LEN
Packit aea12f
#define EALG_MAX_BLOCK_LEN 16
Packit aea12f
#endif
Packit aea12f
Packit aea12f
int _gnutls_cryptodev_fd = -1;
Packit aea12f
Packit aea12f
static int register_mac_digest(int cfd);
Packit aea12f
Packit aea12f
struct cryptodev_ctx {
Packit aea12f
	struct session_op sess;
Packit aea12f
	struct crypt_op cryp;
Packit aea12f
	uint8_t iv[EALG_MAX_BLOCK_LEN];
Packit aea12f
Packit aea12f
	int cfd;
Packit aea12f
};
Packit aea12f
Packit aea12f
static const int gnutls_cipher_map[] = {
Packit aea12f
	[GNUTLS_CIPHER_AES_128_CBC] = CRYPTO_AES_CBC,
Packit aea12f
	[GNUTLS_CIPHER_AES_192_CBC] = CRYPTO_AES_CBC,
Packit aea12f
	[GNUTLS_CIPHER_AES_256_CBC] = CRYPTO_AES_CBC,
Packit aea12f
	[GNUTLS_CIPHER_3DES_CBC] = CRYPTO_3DES_CBC,
Packit aea12f
	[GNUTLS_CIPHER_CAMELLIA_128_CBC] = CRYPTO_CAMELLIA_CBC,
Packit aea12f
	[GNUTLS_CIPHER_CAMELLIA_192_CBC] = CRYPTO_CAMELLIA_CBC,
Packit aea12f
	[GNUTLS_CIPHER_CAMELLIA_256_CBC] = CRYPTO_CAMELLIA_CBC,
Packit aea12f
	[GNUTLS_CIPHER_DES_CBC] = CRYPTO_DES_CBC,
Packit aea12f
};
Packit aea12f
Packit aea12f
static int
Packit aea12f
cryptodev_cipher_init(gnutls_cipher_algorithm_t algorithm, void **_ctx,
Packit aea12f
		      int enc)
Packit aea12f
{
Packit aea12f
	struct cryptodev_ctx *ctx;
Packit aea12f
	int cipher = gnutls_cipher_map[algorithm];
Packit aea12f
Packit aea12f
	*_ctx = gnutls_calloc(1, sizeof(struct cryptodev_ctx));
Packit aea12f
	if (*_ctx == NULL) {
Packit aea12f
		gnutls_assert();
Packit aea12f
		return GNUTLS_E_MEMORY_ERROR;
Packit aea12f
	}
Packit aea12f
Packit aea12f
	ctx = *_ctx;
Packit aea12f
Packit aea12f
	ctx->cfd = _gnutls_cryptodev_fd;
Packit aea12f
	ctx->sess.cipher = cipher;
Packit aea12f
	ctx->cryp.iv = ctx->iv;
Packit aea12f
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
static int
Packit aea12f
cryptodev_cipher_setkey(void *_ctx, const void *key, size_t keysize)
Packit aea12f
{
Packit aea12f
	struct cryptodev_ctx *ctx = _ctx;
Packit aea12f
Packit aea12f
	CHECK_AES_KEYSIZE(keysize);
Packit aea12f
Packit aea12f
	ctx->sess.keylen = keysize;
Packit aea12f
	ctx->sess.key = (void *) key;
Packit aea12f
Packit aea12f
	if (ioctl(ctx->cfd, CIOCGSESSION, &ctx->sess)) {
Packit aea12f
		gnutls_assert();
Packit aea12f
		return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
Packit aea12f
	}
Packit aea12f
	ctx->cryp.ses = ctx->sess.ses;
Packit aea12f
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
static int cryptodev_setiv(void *_ctx, const void *iv, size_t iv_size)
Packit aea12f
{
Packit aea12f
	struct cryptodev_ctx *ctx = _ctx;
Packit aea12f
Packit aea12f
	if (iv_size > EALG_MAX_BLOCK_LEN)
Packit aea12f
		return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
Packit aea12f
Packit aea12f
	memcpy(ctx->iv, iv, iv_size);
Packit aea12f
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
static int
Packit aea12f
cryptodev_encrypt(void *_ctx, const void *src, size_t src_size,
Packit aea12f
		  void *dst, size_t dst_size)
Packit aea12f
{
Packit aea12f
	struct cryptodev_ctx *ctx = _ctx;
Packit aea12f
	ctx->cryp.len = src_size;
Packit aea12f
	ctx->cryp.src = (void *) src;
Packit aea12f
	ctx->cryp.dst = dst;
Packit aea12f
	ctx->cryp.op = COP_ENCRYPT;
Packit aea12f
	ctx->cryp.flags = COP_FLAG_WRITE_IV;
Packit aea12f
Packit aea12f
	if (ioctl(ctx->cfd, CIOCCRYPT, &ctx->cryp)) {
Packit aea12f
		gnutls_assert();
Packit aea12f
		return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
Packit aea12f
	}
Packit aea12f
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
static int
Packit aea12f
cryptodev_decrypt(void *_ctx, const void *src, size_t src_size,
Packit aea12f
		  void *dst, size_t dst_size)
Packit aea12f
{
Packit aea12f
	struct cryptodev_ctx *ctx = _ctx;
Packit aea12f
Packit aea12f
	ctx->cryp.len = src_size;
Packit aea12f
	ctx->cryp.src = (void *) src;
Packit aea12f
	ctx->cryp.dst = dst;
Packit aea12f
	ctx->cryp.op = COP_DECRYPT;
Packit aea12f
	ctx->cryp.flags = COP_FLAG_WRITE_IV;
Packit aea12f
Packit aea12f
	if (ioctl(ctx->cfd, CIOCCRYPT, &ctx->cryp)) {
Packit aea12f
		gnutls_assert();
Packit aea12f
		return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
Packit aea12f
	}
Packit aea12f
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
static void cryptodev_deinit(void *_ctx)
Packit aea12f
{
Packit aea12f
	struct cryptodev_ctx *ctx = _ctx;
Packit aea12f
Packit aea12f
	ioctl(ctx->cfd, CIOCFSESSION, &ctx->sess.ses);
Packit aea12f
	gnutls_free(ctx);
Packit aea12f
}
Packit aea12f
Packit aea12f
static const gnutls_crypto_cipher_st cipher_struct = {
Packit aea12f
	.init = cryptodev_cipher_init,
Packit aea12f
	.setkey = cryptodev_cipher_setkey,
Packit aea12f
	.setiv = cryptodev_setiv,
Packit aea12f
	.encrypt = cryptodev_encrypt,
Packit aea12f
	.decrypt = cryptodev_decrypt,
Packit aea12f
	.deinit = cryptodev_deinit,
Packit aea12f
};
Packit aea12f
Packit aea12f
static int register_crypto(int cfd)
Packit aea12f
{
Packit aea12f
	struct session_op sess;
Packit aea12f
	uint8_t fake_key[CRYPTO_CIPHER_MAX_KEY_LEN];
Packit aea12f
	unsigned int i;
Packit aea12f
	int ret;
Packit aea12f
#ifdef CIOCGSESSINFO
Packit aea12f
	struct session_info_op siop;
Packit aea12f
#endif
Packit aea12f
Packit aea12f
	memset(&sess, 0, sizeof(sess));
Packit aea12f
Packit aea12f
	for (i = 0;
Packit aea12f
	     i < sizeof(gnutls_cipher_map) / sizeof(gnutls_cipher_map[0]);
Packit aea12f
	     i++) {
Packit aea12f
		if (gnutls_cipher_map[i] == 0)
Packit aea12f
			continue;
Packit aea12f
Packit aea12f
		/* test if a cipher is supported and if yes register it */
Packit aea12f
		sess.cipher = gnutls_cipher_map[i];
Packit aea12f
		sess.keylen = gnutls_cipher_get_key_size(i);
Packit aea12f
		sess.key = fake_key;
Packit aea12f
Packit aea12f
		if (ioctl(cfd, CIOCGSESSION, &sess)) {
Packit aea12f
			continue;
Packit aea12f
		}
Packit aea12f
#ifdef CIOCGSESSINFO
Packit aea12f
		memset(&siop, 0, sizeof(siop));
Packit aea12f
Packit aea12f
		siop.ses = sess.ses;	/* do not register ciphers that are not hw accelerated */
Packit aea12f
		if (ioctl(cfd, CIOCGSESSINFO, &siop) == 0) {
Packit aea12f
			if (!(siop.flags & SIOP_FLAG_KERNEL_DRIVER_ONLY)) {
Packit aea12f
				ioctl(cfd, CIOCFSESSION, &sess.ses);
Packit aea12f
				continue;
Packit aea12f
			}
Packit aea12f
		}
Packit aea12f
#endif
Packit aea12f
Packit aea12f
		ioctl(cfd, CIOCFSESSION, &sess.ses);
Packit aea12f
Packit aea12f
		_gnutls_debug_log("/dev/crypto: registering: %s\n",
Packit aea12f
				  gnutls_cipher_get_name(i));
Packit aea12f
		ret =
Packit aea12f
		    gnutls_crypto_single_cipher_register(i, 90,
Packit aea12f
							 &cipher_struct, 0);
Packit aea12f
		if (ret < 0) {
Packit aea12f
			gnutls_assert();
Packit aea12f
			return ret;
Packit aea12f
		}
Packit aea12f
Packit aea12f
	}
Packit aea12f
Packit aea12f
#ifdef CIOCAUTHCRYPT
Packit aea12f
	return _cryptodev_register_gcm_crypto(cfd);
Packit aea12f
#else
Packit aea12f
	return 0;
Packit aea12f
#endif
Packit aea12f
}
Packit aea12f
Packit aea12f
int _gnutls_cryptodev_init(void)
Packit aea12f
{
Packit aea12f
	int ret;
Packit aea12f
Packit aea12f
	/* Open the crypto device */
Packit aea12f
	_gnutls_cryptodev_fd = open("/dev/crypto", O_RDWR, 0);
Packit aea12f
	if (_gnutls_cryptodev_fd < 0) {
Packit aea12f
		gnutls_assert();
Packit aea12f
		return GNUTLS_E_CRYPTODEV_DEVICE_ERROR;
Packit aea12f
	}
Packit aea12f
#ifndef CRIOGET_NOT_NEEDED
Packit aea12f
	{
Packit aea12f
		int cfd = -1;
Packit aea12f
		/* Clone file descriptor */
Packit aea12f
		if (ioctl(_gnutls_cryptodev_fd, CRIOGET, &cfd)) {
Packit aea12f
			gnutls_assert();
Packit aea12f
			return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
Packit aea12f
		}
Packit aea12f
Packit aea12f
		/* Set close-on-exec (not really needed here) */
Packit aea12f
		if (fcntl(cfd, F_SETFD, 1) == -1) {
Packit aea12f
			gnutls_assert();
Packit aea12f
			return GNUTLS_E_CRYPTODEV_IOCTL_ERROR;
Packit aea12f
		}
Packit aea12f
Packit aea12f
		close(_gnutls_cryptodev_fd);
Packit aea12f
		_gnutls_cryptodev_fd = cfd;
Packit aea12f
	}
Packit aea12f
#endif
Packit aea12f
Packit aea12f
	ret = register_crypto(_gnutls_cryptodev_fd);
Packit aea12f
	if (ret < 0)
Packit aea12f
		gnutls_assert();
Packit aea12f
Packit aea12f
	if (ret >= 0) {
Packit aea12f
		ret = register_mac_digest(_gnutls_cryptodev_fd);
Packit aea12f
		if (ret < 0)
Packit aea12f
			gnutls_assert();
Packit aea12f
	}
Packit aea12f
Packit aea12f
	if (ret < 0) {
Packit aea12f
		gnutls_assert();
Packit aea12f
		close(_gnutls_cryptodev_fd);
Packit aea12f
	}
Packit aea12f
Packit aea12f
	return ret;
Packit aea12f
}
Packit aea12f
Packit aea12f
void _gnutls_cryptodev_deinit(void)
Packit aea12f
{
Packit aea12f
	if (_gnutls_cryptodev_fd != -1)
Packit aea12f
		close(_gnutls_cryptodev_fd);
Packit aea12f
}
Packit aea12f
Packit aea12f
/* MAC and digest stuff */
Packit aea12f
Packit aea12f
/* if we are using linux /dev/crypto
Packit aea12f
 */
Packit aea12f
#if defined(COP_FLAG_UPDATE) && defined(COP_FLAG_RESET)
Packit aea12f
Packit aea12f
static const int gnutls_mac_map[] = {
Packit aea12f
	[GNUTLS_MAC_MD5] = CRYPTO_MD5_HMAC,
Packit aea12f
	[GNUTLS_MAC_SHA1] = CRYPTO_SHA1_HMAC,
Packit aea12f
	[GNUTLS_MAC_SHA256] = CRYPTO_SHA2_256_HMAC,
Packit aea12f
	[GNUTLS_MAC_SHA384] = CRYPTO_SHA2_384_HMAC,
Packit aea12f
	[GNUTLS_MAC_SHA512] = CRYPTO_SHA2_512_HMAC,
Packit aea12f
};
Packit aea12f
Packit aea12f
static int
Packit aea12f
cryptodev_mac_fast(gnutls_mac_algorithm_t algo,
Packit aea12f
		   const void *nonce, size_t nonce_size,
Packit aea12f
		   const void *key, size_t key_size, const void *text,
Packit aea12f
		   size_t text_size, void *digest)
Packit aea12f
{
Packit aea12f
	struct cryptodev_ctx ctx;
Packit aea12f
	int ret;
Packit aea12f
Packit aea12f
	assert(nonce_size == 0);
Packit aea12f
Packit aea12f
	memset(&ctx, 0, sizeof(ctx));
Packit aea12f
	ctx.cfd = _gnutls_cryptodev_fd;
Packit aea12f
	ctx.sess.mac = gnutls_mac_map[algo];
Packit aea12f
Packit aea12f
	ctx.sess.mackeylen = key_size;
Packit aea12f
	ctx.sess.mackey = (void *) key;
Packit aea12f
Packit aea12f
	if (ioctl(ctx.cfd, CIOCGSESSION, &ctx.sess))
Packit aea12f
		return gnutls_assert_val(GNUTLS_E_CRYPTODEV_IOCTL_ERROR);
Packit aea12f
Packit aea12f
	ctx.cryp.ses = ctx.sess.ses;
Packit aea12f
Packit aea12f
	ctx.cryp.len = text_size;
Packit aea12f
	ctx.cryp.src = (void *) text;
Packit aea12f
	ctx.cryp.dst = NULL;
Packit aea12f
	ctx.cryp.op = COP_ENCRYPT;
Packit aea12f
	ctx.cryp.mac = digest;
Packit aea12f
Packit aea12f
	ret = ioctl(ctx.cfd, CIOCCRYPT, &ctx.cryp);
Packit aea12f
Packit aea12f
	ioctl(_gnutls_cryptodev_fd, CIOCFSESSION, &ctx.sess.ses);
Packit aea12f
	if (ret != 0)
Packit aea12f
		return gnutls_assert_val(GNUTLS_E_CRYPTODEV_IOCTL_ERROR);
Packit aea12f
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
#define cryptodev_mac_deinit cryptodev_deinit
Packit aea12f
Packit aea12f
static const gnutls_crypto_mac_st mac_struct = {
Packit aea12f
	.init = NULL,
Packit aea12f
	.setkey = NULL,
Packit aea12f
	.setnonce = NULL,
Packit aea12f
	.hash = NULL,
Packit aea12f
	.output = NULL,
Packit aea12f
	.deinit = NULL,
Packit aea12f
	.fast = cryptodev_mac_fast
Packit aea12f
};
Packit aea12f
Packit aea12f
/* Digest algorithms */
Packit aea12f
Packit aea12f
static const int gnutls_digest_map[] = {
Packit aea12f
	[GNUTLS_DIG_MD5] = CRYPTO_MD5,
Packit aea12f
	[GNUTLS_DIG_SHA1] = CRYPTO_SHA1,
Packit aea12f
	[GNUTLS_DIG_SHA256] = CRYPTO_SHA2_256,
Packit aea12f
	[GNUTLS_DIG_SHA384] = CRYPTO_SHA2_384,
Packit aea12f
	[GNUTLS_DIG_SHA512] = CRYPTO_SHA2_512,
Packit aea12f
};
Packit aea12f
Packit aea12f
static int
Packit aea12f
cryptodev_digest_fast(gnutls_digest_algorithm_t algo,
Packit aea12f
		      const void *text, size_t text_size, void *digest)
Packit aea12f
{
Packit aea12f
	struct cryptodev_ctx ctx;
Packit aea12f
	int ret;
Packit aea12f
Packit aea12f
	memset(&ctx, 0, sizeof(ctx));
Packit aea12f
	ctx.cfd = _gnutls_cryptodev_fd;
Packit aea12f
	ctx.sess.mac = gnutls_digest_map[algo];
Packit aea12f
Packit aea12f
	if (ioctl(ctx.cfd, CIOCGSESSION, &ctx.sess))
Packit aea12f
		return gnutls_assert_val(GNUTLS_E_CRYPTODEV_IOCTL_ERROR);
Packit aea12f
Packit aea12f
	ctx.cryp.ses = ctx.sess.ses;
Packit aea12f
Packit aea12f
	ctx.cryp.len = text_size;
Packit aea12f
	ctx.cryp.src = (void *) text;
Packit aea12f
	ctx.cryp.dst = NULL;
Packit aea12f
	ctx.cryp.op = COP_ENCRYPT;
Packit aea12f
	ctx.cryp.mac = digest;
Packit aea12f
Packit aea12f
	ret = ioctl(ctx.cfd, CIOCCRYPT, &ctx.cryp);
Packit aea12f
Packit aea12f
	ioctl(_gnutls_cryptodev_fd, CIOCFSESSION, &ctx.sess.ses);
Packit aea12f
	if (ret != 0)
Packit aea12f
		return gnutls_assert_val(GNUTLS_E_CRYPTODEV_IOCTL_ERROR);
Packit aea12f
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
static const gnutls_crypto_digest_st digest_struct = {
Packit aea12f
	.init = NULL,
Packit aea12f
	.hash = NULL,
Packit aea12f
	.output = NULL,
Packit aea12f
	.deinit = NULL,
Packit aea12f
	.fast = cryptodev_digest_fast
Packit aea12f
};
Packit aea12f
Packit aea12f
static int register_mac_digest(int cfd)
Packit aea12f
{
Packit aea12f
	struct session_op sess;
Packit aea12f
	uint8_t fake_key[CRYPTO_CIPHER_MAX_KEY_LEN];
Packit aea12f
	unsigned int i;
Packit aea12f
	int ret;
Packit aea12f
#ifdef CIOCGSESSINFO
Packit aea12f
	struct session_info_op siop;
Packit aea12f
#endif
Packit aea12f
Packit aea12f
	memset(&sess, 0, sizeof(sess));
Packit aea12f
	for (i = 0; i < sizeof(gnutls_mac_map) / sizeof(gnutls_mac_map[0]);
Packit aea12f
	     i++) {
Packit aea12f
		if (gnutls_mac_map[i] == 0)
Packit aea12f
			continue;
Packit aea12f
Packit aea12f
		sess.mac = gnutls_mac_map[i];
Packit aea12f
		sess.mackeylen = 8;
Packit aea12f
		sess.mackey = fake_key;
Packit aea12f
Packit aea12f
		if (ioctl(cfd, CIOCGSESSION, &sess)) {
Packit aea12f
			continue;
Packit aea12f
		}
Packit aea12f
#ifdef CIOCGSESSINFO
Packit aea12f
		memset(&siop, 0, sizeof(siop));
Packit aea12f
Packit aea12f
		siop.ses = sess.ses;	/* do not register ciphers that are not hw accelerated */
Packit aea12f
		if (ioctl(cfd, CIOCGSESSINFO, &siop) == 0) {
Packit aea12f
			if (!(siop.flags & SIOP_FLAG_KERNEL_DRIVER_ONLY)) {
Packit aea12f
				ioctl(cfd, CIOCFSESSION, &sess.ses);
Packit aea12f
				continue;
Packit aea12f
			}
Packit aea12f
		}
Packit aea12f
#endif
Packit aea12f
		_gnutls_debug_log("/dev/crypto: registering: HMAC-%s\n",
Packit aea12f
				  gnutls_mac_get_name(i));
Packit aea12f
Packit aea12f
		ioctl(cfd, CIOCFSESSION, &sess.ses);
Packit aea12f
Packit aea12f
		ret =
Packit aea12f
		    gnutls_crypto_single_mac_register(i, 90, &mac_struct, 0);
Packit aea12f
		if (ret < 0) {
Packit aea12f
			gnutls_assert();
Packit aea12f
			return ret;
Packit aea12f
		}
Packit aea12f
	}
Packit aea12f
Packit aea12f
	memset(&sess, 0, sizeof(sess));
Packit aea12f
	for (i = 0;
Packit aea12f
	     i < sizeof(gnutls_digest_map) / sizeof(gnutls_digest_map[0]);
Packit aea12f
	     i++) {
Packit aea12f
		if (gnutls_digest_map[i] == 0)
Packit aea12f
			continue;
Packit aea12f
Packit aea12f
		sess.mac = gnutls_digest_map[i];
Packit aea12f
Packit aea12f
		if (ioctl(cfd, CIOCGSESSION, &sess)) {
Packit aea12f
			continue;
Packit aea12f
		}
Packit aea12f
#ifdef CIOCGSESSINFO
Packit aea12f
		memset(&siop, 0, sizeof(siop));
Packit aea12f
Packit aea12f
		siop.ses = sess.ses;
Packit aea12f
		if (ioctl(cfd, CIOCGSESSINFO, &siop) == 0) {
Packit aea12f
			if (!(siop.flags & SIOP_FLAG_KERNEL_DRIVER_ONLY)) {
Packit aea12f
				ioctl(cfd, CIOCFSESSION, &sess.ses);
Packit aea12f
				continue;
Packit aea12f
			}
Packit aea12f
		}
Packit aea12f
#endif
Packit aea12f
Packit aea12f
		ioctl(cfd, CIOCFSESSION, &sess.ses);
Packit aea12f
Packit aea12f
		_gnutls_debug_log("/dev/crypto: registering: %s\n",
Packit aea12f
				  gnutls_mac_get_name(i));
Packit aea12f
		ret =
Packit aea12f
		    gnutls_crypto_single_digest_register(i, 90,
Packit aea12f
							 &digest_struct, 0);
Packit aea12f
		if (ret < 0) {
Packit aea12f
			gnutls_assert();
Packit aea12f
			return ret;
Packit aea12f
		}
Packit aea12f
	}
Packit aea12f
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
#else
Packit aea12f
static int register_mac_digest(int cfd)
Packit aea12f
{
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
#endif				/* defined(COP_FLAG_UPDATE) */
Packit aea12f
Packit aea12f
#else				/* ENABLE_CRYPTODEV */
Packit aea12f
int _gnutls_cryptodev_init(void)
Packit aea12f
{
Packit aea12f
	return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
void _gnutls_cryptodev_deinit(void)
Packit aea12f
{
Packit aea12f
	return;
Packit aea12f
}
Packit aea12f
#endif				/* ENABLE_CRYPTODEV */