---
cryptodev.h | 4 ++--
cryptodev_int.h | 2 --
cryptodev_main.c | 4 +++-
examples/async_cipher.c | 45 ++++++++++++++++++++++++++++++++++++++-------
examples/async_speed.c | 25 ++++++++++++++++++++++---
examples/cipher.c | 28 ++++++++++++++++++++--------
examples/speed.c | 15 +++++++++++++--
7 files changed, 98 insertions(+), 25 deletions(-)
diff --git a/cryptodev.h b/cryptodev.h
index 9cb2764..c50505b 100644
--- a/cryptodev.h
+++ b/cryptodev.h
@@ -84,8 +84,6 @@ struct session_op {
__u8 __user *mackey;
__u32 ses; /* session identifier */
-
- __u16 alignmask; /* alignment constraints */
};
struct session_info_op {
@@ -96,6 +94,8 @@ struct session_info_op {
char cra_name[CRYPTODEV_MAX_ALG_NAME];
char cra_driver_name[CRYPTODEV_MAX_ALG_NAME];
} cipher_info, hash_info;
+
+ __u16 alignmask; /* alignment constraints */
};
#define COP_ENCRYPT 0
diff --git a/cryptodev_int.h b/cryptodev_int.h
index 4d9d6f6..4be66ec 100644
--- a/cryptodev_int.h
+++ b/cryptodev_int.h
@@ -103,8 +103,6 @@ struct compat_session_op {
compat_uptr_t mackey; /* pointer to mac key data */
uint32_t ses; /* session identifier */
-
- uint16_t alignmask; /* alignment constraints */
};
/* input of CIOCCRYPT */
diff --git a/cryptodev_main.c b/cryptodev_main.c
index 17155bf..871690b 100644
--- a/cryptodev_main.c
+++ b/cryptodev_main.c
@@ -291,7 +291,7 @@ crypto_create_session(struct fcrypt *fcr, struct session_op
*sop)
}
}
- sop->alignmask = ses_new->alignmask = max(ses_new->cdata.alignmask,
+ ses_new->alignmask = max(ses_new->cdata.alignmask,
ses_new->hdata.alignmask);
dprintk(2, KERN_DEBUG, "%s: got alignmask %d\n", __func__,
ses_new->alignmask);
@@ -1036,6 +1036,8 @@ static int get_session_info(struct fcrypt *fcr, struct
session_info_op *siop)
crypto_ahash_tfm(ses_ptr->hdata.async.s));
}
+ siop->alignmask = ses_ptr->alignmask;
+
mutex_unlock(&ses_ptr->sem);
return 0;
}
diff --git a/examples/async_cipher.c b/examples/async_cipher.c
index 314c36a..e89c7f2 100644
--- a/examples/async_cipher.c
+++ b/examples/async_cipher.c
@@ -28,6 +28,9 @@ test_crypto(int cfd)
char key[KEY_SIZE];
struct session_op sess;
+#ifdef CIOCGSESSINFO
+ struct session_info_op siop;
+#endif
struct crypt_op cryp;
printf("running %s\n", __func__);
@@ -49,9 +52,18 @@ test_crypto(int cfd)
printf("%s: got the session\n", __func__);
-
- plaintext = (char *)(((unsigned long)plaintext_raw + sess.alignmask) &
~sess.alignmask);
- ciphertext = (char *)(((unsigned long)ciphertext_raw + sess.alignmask)
& ~sess.alignmask);
+#ifdef CIOCGSESSINFO
+ siop.ses = sess.ses;
+ if (ioctl(cfd, CIOCGSESSINFO, &siop)) {
+ perror("ioctl(CIOCGSESSINFO)");
+ return 1;
+ }
+ plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) &
~siop.alignmask);
+ ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask)
& ~siop.alignmask);
+#else
+ plaintext = plaintext_raw;
+ ciphertext = ciphertext_raw;
+#endif
memset(plaintext, 0x15, DATA_SIZE);
/* Encrypt data.in to data.encrypted */
@@ -122,6 +134,9 @@ static int test_aes(int cfd)
char key2[KEY_SIZE];
struct session_op sess1, sess2;
+#ifdef CIOCGSESSINFO
+ struct session_info_op siop1, siop2;
+#endif
struct crypt_op cryp1, cryp2;
memset(&sess1, 0, sizeof(sess1));
@@ -137,8 +152,16 @@ static int test_aes(int cfd)
perror("ioctl(CIOCGSESSION)");
return 1;
}
-
- plaintext1 = (char *)(((unsigned long)plaintext1_raw + sess1.alignmask)
& ~sess1.alignmask);
+#ifdef CIOCGSESSINFO
+ siop1.ses = sess1.ses;
+ if (ioctl(cfd, CIOCGSESSINFO, &siop1)) {
+ perror("ioctl(CIOCGSESSINFO)");
+ return 1;
+ }
+ plaintext1 = (char *)(((unsigned long)plaintext1_raw + siop1.alignmask)
& ~siop1.alignmask);
+#else
+ plaintext1 = plaintext1_raw;
+#endif
memset(plaintext1, 0x0, BLOCK_SIZE);
memset(iv1, 0x0, sizeof(iv1));
@@ -152,8 +175,16 @@ static int test_aes(int cfd)
perror("ioctl(CIOCGSESSION)");
return 1;
}
-
- plaintext2 = (char *)(((unsigned long)plaintext2_raw + sess2.alignmask)
& ~sess2.alignmask);
+#ifdef CIOCGSESSINFO
+ siop2.ses = sess2.ses;
+ if (ioctl(cfd, CIOCGSESSINFO, &siop2)) {
+ perror("ioctl(CIOCGSESSINFO)");
+ return 1;
+ }
+ plaintext2 = (char *)(((unsigned long)plaintext2_raw + siop2.alignmask)
& ~siop2.alignmask);
+#else
+ plaintext2 = plaintext2_raw;
+#endif
memcpy(plaintext2, plaintext2_data, BLOCK_SIZE);
/* Encrypt data.in to data.encrypted */
diff --git a/examples/async_speed.c b/examples/async_speed.c
index 940d923..4aea5e3 100644
--- a/examples/async_speed.c
+++ b/examples/async_speed.c
@@ -144,8 +144,11 @@ int encrypt_data(struct session_op *sess, int fdc, int
chunksize, int alignmask)
int main(void)
{
- int fd, i, fdc = -1;
+ int fd, i, fdc = -1, alignmask = 0;
struct session_op sess;
+#ifdef CIOCGSESSINFO
+ struct session_info_op siop;
+#endif
char keybuf[32];
signal(SIGALRM, alarm_handler);
@@ -168,9 +171,17 @@ int main(void)
perror("ioctl(CIOCGSESSION)");
return 1;
}
+#ifdef CIOCGSESSINFO
+ siop.ses = sess.ses;
+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) {
+ perror("ioctl(CIOCGSESSINFO)");
+ return 1;
+ }
+ alignmask = siop.alignmask;
+#endif
for (i = 256; i <= (64 * 4096); i *= 2) {
- if (encrypt_data(&sess, fdc, i, sess.alignmask))
+ if (encrypt_data(&sess, fdc, i, alignmask))
break;
}
@@ -184,9 +195,17 @@ int main(void)
perror("ioctl(CIOCGSESSION)");
return 1;
}
+#ifdef CIOCGSESSINFO
+ siop.ses = sess.ses;
+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) {
+ perror("ioctl(CIOCGSESSINFO)");
+ return 1;
+ }
+ alignmask = siop.alignmask;
+#endif
for (i = 256; i <= (64 * 1024); i *= 2) {
- if (encrypt_data(&sess, fdc, i, sess.alignmask))
+ if (encrypt_data(&sess, fdc, i, alignmask))
break;
}
diff --git a/examples/cipher.c b/examples/cipher.c
index 9f19c5e..007d3fe 100644
--- a/examples/cipher.c
+++ b/examples/cipher.c
@@ -53,10 +53,13 @@ test_crypto(int cfd)
}
printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n",
siop.cipher_info.cra_name,
siop.cipher_info.cra_driver_name);
-#endif
- plaintext = (char *)(((unsigned long)plaintext_raw + sess.alignmask) &
~sess.alignmask);
- ciphertext = (char *)(((unsigned long)ciphertext_raw + sess.alignmask)
& ~sess.alignmask);
+ plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) &
~siop.alignmask);
+ ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask)
& ~siop.alignmask);
+#else
+ plaintext = plaintext_raw;
+ ciphertext = ciphertext_raw;
+#endif
memset(plaintext, 0x15, DATA_SIZE);
/* Encrypt data.in to data.encrypted */
@@ -163,9 +166,16 @@ static int test_aes(int cfd)
perror("ioctl(CIOCGSESSION)");
return 1;
}
-
- plaintext1 = (char *)(((unsigned long)plaintext1_raw + sess.alignmask)
& ~sess.alignmask);
-
+#ifdef CIOCGSESSINFO
+ siop.ses = sess.ses;
+ if (ioctl(cfd, CIOCGSESSINFO, &siop)) {
+ perror("ioctl(CIOCGSESSINFO)");
+ return 1;
+ }
+ plaintext1 = (char *)(((unsigned long)plaintext1_raw + siop.alignmask)
& ~siop.alignmask);
+#else
+ plaintext1 = plaintext1_raw;
+#endif
memset(plaintext1, 0x0, BLOCK_SIZE);
memset(iv1, 0x0, sizeof(iv1));
@@ -210,9 +220,11 @@ static int test_aes(int cfd)
}
printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n",
siop.cipher_info.cra_name,
siop.cipher_info.cra_driver_name);
-#endif
- plaintext2 = (char *)(((unsigned long)plaintext2_raw + sess.alignmask)
& ~sess.alignmask);
+ plaintext2 = (char *)(((unsigned long)plaintext2_raw + siop.alignmask)
& ~siop.alignmask);
+#else
+ plaintext2 = plaintext2_raw;
+#endif
memcpy(plaintext2, plaintext2_data, BLOCK_SIZE);
/* Encrypt data.in to data.encrypted */
diff --git a/examples/speed.c b/examples/speed.c
index 38b3821..e2985ff 100644
--- a/examples/speed.c
+++ b/examples/speed.c
@@ -129,8 +129,11 @@ int encrypt_data(struct session_op *sess, int fdc, int
chunksize, int alignmask)
int main(int argc, char** argv)
{
- int fd, i, fdc = -1;
+ int fd, i, fdc = -1, alignmask = 0;
struct session_op sess;
+#ifdef CIOCGSESSINFO
+ struct session_info_op siop;
+#endif
char keybuf[32];
signal(SIGALRM, alarm_handler);
@@ -163,9 +166,17 @@ int main(int argc, char** argv)
perror("ioctl(CIOCGSESSION)");
return 1;
}
+#ifdef CIOCGSESSINFO
+ siop.ses = sess.ses;
+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) {
+ perror("ioctl(CIOCGSESSINFO)");
+ return 1;
+ }
+ alignmask = siop.alignmask;
+#endif
for (i = 256; i <= (64 * 4096); i *= 2) {
- if (encrypt_data(&sess, fdc, i, sess.alignmask))
+ if (encrypt_data(&sess, fdc, i, alignmask))
break;
}
--
1.7.3.4
_______________________________________________
Cryptodev-linux-devel mailing list
[email protected]
https://mail.gna.org/listinfo/cryptodev-linux-devel