CRIOGET is gone. Saves one ioctl per session.

This commit is contained in:
tls 2008-01-26 20:46:21 +00:00
parent 287ee4e9a9
commit 4781622c25

View File

@ -2,6 +2,7 @@
* Copyright (c) 2002 Bob Beck <beck@openbsd.org>
* Copyright (c) 2002 Theo de Raadt
* Copyright (c) 2002 Markus Friedl
* Copyright (c) 2008 Coyote Point Systems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -175,22 +176,12 @@ open_dev_crypto(void)
static int
get_dev_crypto(void)
{
int fd;
static int retfd = -1;
static int fd = -1;
if (retfd == -1) {
if ((fd = open_dev_crypto()) == -1)
return (-1);
if (ioctl(fd, CRIOGET, &retfd) == -1)
return (-1);
/* close on exec */
if (fcntl(retfd, F_SETFD, 1) == -1) {
close(retfd);
return (-1);
}
if (fd == -1) {
fd = open_dev_crypto();
}
return (retfd);
return (fd);
}
/*
@ -267,7 +258,6 @@ get_cryptodev_ciphers(const int **cnids)
ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
nids[count++] = ciphers[i].nid;
}
close(fd);
if (count > 0)
*cnids = nids;
@ -303,7 +293,6 @@ get_cryptodev_digests(const int **cnids)
ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
nids[count++] = digests[i].nid;
}
close(fd);
if (count > 0)
*cnids = nids;
@ -439,7 +428,6 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
sess->cipher = cipher;
if (ioctl(state->d_fd, CIOCGSESSION, sess) == -1) {
close(state->d_fd);
state->d_fd = -1;
return (0);
}
@ -476,7 +464,6 @@ cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
} else {
ret = 1;
}
close(state->d_fd);
state->d_fd = -1;
return (ret);
@ -1052,11 +1039,9 @@ ENGINE_load_cryptodev(void)
* find out what asymmetric crypto algorithms we support
*/
if (ioctl(fd, CIOCASYMFEAT, &cryptodev_asymfeat) == -1) {
close(fd);
ENGINE_free(engine);
return;
}
close(fd);
if (!ENGINE_set_id(engine, "cryptodev") ||
!ENGINE_set_name(engine, "BSD cryptodev engine") ||