Signed-off-by: Phil Sutter <phil.sut...@viprinet.com> --- authenc.c | 28 ++++++++++++++-------------- cryptlib.c | 2 +- cryptlib.h | 2 +- cryptodev_int.h | 2 +- ioctl.c | 4 ++-- lib/benchmark.c | 8 ++++---- lib/combo.c | 22 +++++++++++----------- lib/hash.c | 16 ++++++++-------- lib/hash.h | 2 +- lib/main.c | 4 ++-- lib/threshold.c | 10 +++++----- main.c | 8 ++++---- zc.c | 26 +++++++++++++------------- zc.h | 2 +- 14 files changed, 68 insertions(+), 68 deletions(-)
diff --git a/authenc.c b/authenc.c index faf0641..718bb52 100644 --- a/authenc.c +++ b/authenc.c @@ -88,7 +88,7 @@ static int get_userbuf_tls(struct csession *ses, struct kernel_crypt_auth_op *kc "failed to get user pages for data input\n"); return -EINVAL; } - + (*dst_sg) = ses->sg; return 0; @@ -220,7 +220,7 @@ static int fill_kcaop_from_caop(struct kernel_crypt_auth_op *kcaop, struct fcryp goto out_unlock; } } - + ret = 0; out_unlock: @@ -322,7 +322,7 @@ static int verify_tls_record_pad( struct scatterlist *dst_sg, int len, int block return pad_size+1; } -/* Authenticate and encrypt the TLS way (also perform padding). +/* Authenticate and encrypt the TLS way (also perform padding). * During decryption it verifies the pad and tag and returns -EBADMSG on error. */ static int @@ -330,7 +330,7 @@ tls_auth_n_crypt(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop, struct scatterlist *auth_sg, uint32_t auth_len, struct scatterlist *dst_sg, uint32_t len) { - int ret, fail = 0; + int ret, fail = 0; struct crypt_auth_op *caop = &kcaop->caop; uint8_t vhash[AALG_MAX_RESULT_LEN]; uint8_t hash_output[AALG_MAX_RESULT_LEN]; @@ -553,7 +553,7 @@ auth_n_crypt(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop, dprintk(0, KERN_ERR, "Illegal tag length: %d\n", caop->tag_len); return -EINVAL; } - + if (caop->tag_len) cryptodev_cipher_set_tag_size(&ses_ptr->cdata, caop->tag_len); else @@ -594,8 +594,8 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcao int ret = 0; if (caop->flags & COP_FLAG_AEAD_SRTP_TYPE) { - if (unlikely(ses_ptr->cdata.init != 0 && - (ses_ptr->cdata.stream == 0 || ses_ptr->cdata.aead != 0))) + if (unlikely(ses_ptr->cdata.init != 0 && + (ses_ptr->cdata.stream == 0 || ses_ptr->cdata.aead != 0))) { dprintk(0, KERN_ERR, "Only stream modes are allowed in SRTP mode (but not AEAD)\n"); return -EINVAL; @@ -607,7 +607,7 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcao return ret; } - ret = srtp_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, + ret = srtp_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, dst_sg, caop->len); release_user_pages(ses_ptr); @@ -649,14 +649,14 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcao goto free_auth_buf; } - ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, + ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, dst_sg, caop->len); } else { int dst_len; - if (unlikely(ses_ptr->cdata.init == 0 || - ses_ptr->cdata.stream == 0 || - ses_ptr->cdata.aead == 0)) + if (unlikely(ses_ptr->cdata.init == 0 || + ses_ptr->cdata.stream == 0 || + ses_ptr->cdata.aead == 0)) { dprintk(0, KERN_ERR, "Only stream and AEAD ciphers are allowed for authenc\n"); ret = -EINVAL; @@ -665,7 +665,7 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcao if (caop->op == COP_ENCRYPT) dst_len = caop->len + cryptodev_cipher_get_tag_size(&ses_ptr->cdata); else dst_len = caop->len - cryptodev_cipher_get_tag_size(&ses_ptr->cdata); - + ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, dst_len, kcaop->task, kcaop->mm, &src_sg, &dst_sg); if (unlikely(ret)) { @@ -673,7 +673,7 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcao goto free_auth_buf; } - ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, + ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, src_sg, dst_sg, caop->len); } diff --git a/cryptlib.c b/cryptlib.c index 51701b3..fad5ba6 100644 --- a/cryptlib.c +++ b/cryptlib.c @@ -221,7 +221,7 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, int ret; INIT_COMPLETION(cdata->async.result->completion); - + if (cdata->aead == 0) { ablkcipher_request_set_crypt(cdata->async.request, (struct scatterlist *)src, dst, diff --git a/cryptlib.h b/cryptlib.h index 52c7a78..729679c 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -34,7 +34,7 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, /* AEAD */ inline static void cryptodev_cipher_auth(struct cipher_data *cdata, - struct scatterlist *sg1, size_t len) + struct scatterlist *sg1, size_t len) { if( len ) aead_request_set_assoc(cdata->async.arequest, sg1, len); diff --git a/cryptodev_int.h b/cryptodev_int.h index f43aef2..12dd5b1 100644 --- a/cryptodev_int.h +++ b/cryptodev_int.h @@ -118,7 +118,7 @@ struct csession { unsigned int array_size; unsigned int used_pages; /* the number of pages that are used */ /* the number of pages marked as NOT-writable; they preceed writeables */ - unsigned int readonly_pages; + unsigned int readonly_pages; struct page **pages; struct scatterlist *sg; }; diff --git a/ioctl.c b/ioctl.c index 74f5363..a81b601 100644 --- a/ioctl.c +++ b/ioctl.c @@ -386,7 +386,7 @@ struct csession * crypto_get_session_by_sid(struct fcrypt *fcr, uint32_t sid) { struct csession *ses_ptr, *retval = NULL; - + if (unlikely(fcr == NULL)) return NULL; @@ -738,7 +738,7 @@ static int get_session_info(struct fcrypt *fcr, struct session_info_op *siop) dprintk(1, KERN_ERR, "invalid session ID=0x%08X\n", siop->ses); return -EINVAL; } - + siop->flags = 0; if (ses_ptr->cdata.init) { diff --git a/lib/benchmark.c b/lib/benchmark.c index 37e9ade..a04efbc 100644 --- a/lib/benchmark.c +++ b/lib/benchmark.c @@ -37,7 +37,7 @@ int start_benchmark(struct benchmark_st * st) { int ret; struct itimerval timer; - + memset(st, 0, sizeof(*st)); st->old_handler = signal (SIGPROF, alarm_handler); @@ -59,12 +59,12 @@ int start_benchmark(struct benchmark_st * st) perror("setitimer"); return -1; } - + return 0; } /* Returns -1 on error or 0 on success. - * elapsed: the elapsed time in milliseconds + * elapsed: the elapsed time in milliseconds */ int stop_benchmark(struct benchmark_st * st, unsigned long * elapsed) { @@ -80,7 +80,7 @@ int stop_benchmark(struct benchmark_st * st, unsigned long * elapsed) msecs = (stop.tv_sec * 1000 + stop.tv_usec / 1000 - (st->start.tv_sec * 1000 + st->start.tv_usec / (1000))); - + if (elapsed) *elapsed = msecs; return 0; diff --git a/lib/combo.c b/lib/combo.c index 6d649cd..b26da0a 100644 --- a/lib/combo.c +++ b/lib/combo.c @@ -41,7 +41,7 @@ int aead_ctx_init(struct cryptodev_ctx* ctx, int cipher, int hash, void* key, in } #ifdef DEBUG printf("Got %s-%s with drivers %s and %s\n", - siop.cipher_info.cra_name, siop.hash_info.cra_name, + siop.cipher_info.cra_name, siop.hash_info.cra_name, siop.cipher_info.cra_driver_name, siop.hash_info.cra_driver_name); #endif /*printf("Alignmask is %x\n", (unsigned int)siop.alignmask);*/ @@ -50,7 +50,7 @@ int aead_ctx_init(struct cryptodev_ctx* ctx, int cipher, int hash, void* key, in return 0; } -void aead_ctx_deinit(struct cryptodev_ctx* ctx) +void aead_ctx_deinit(struct cryptodev_ctx* ctx) { if (ioctl(ctx->cfd, CIOCFSESSION, &ctx->sess.ses)) { perror("ioctl(CIOCFSESSION)"); @@ -61,7 +61,7 @@ int aead_encrypt(struct cryptodev_ctx* ctx, const void* iv, const void* plaintext, void* ciphertext, size_t size, void* digest) { struct crypt_auth_op cryp; - + memset(&cryp, 0, sizeof(cryp)); /* Encrypt data.in to data.encrypted */ @@ -84,7 +84,7 @@ aead_encrypt(struct cryptodev_ctx* ctx, const void* iv, const void* plaintext, v static const int sizes[] = {64, 256, 512, 1024, 4096, 16*1024}; -int aead_test(int cipher, int mac, void* ukey, int ukey_size, +int aead_test(int cipher, int mac, void* ukey, int ukey_size, void* user_ctx, void (*user_combo)(void* user_ctx, void* plaintext, void* ciphertext, int size, void* res)) { int cfd = -1, i, ret; @@ -105,7 +105,7 @@ int aead_test(int cipher, int mac, void* ukey, int ukey_size, } aead_ctx_init(&ctx, cipher, mac, ukey, ukey_size, cfd); - + for (i=0;i<sizeof(sizes)/sizeof(sizes[0]);i++) { counted = 0; ret = start_benchmark(&bst); @@ -119,13 +119,13 @@ int aead_test(int cipher, int mac, void* ukey, int ukey_size, return -2; counted += sizes[i]; } while(benchmark_must_finish==0); - + ret = stop_benchmark(&bst, &elapsed); if (ret < 0) { ret = -1; goto finish; } - + t1 = (double)counted/(double)elapsed; /* now check the user function */ @@ -140,15 +140,15 @@ int aead_test(int cipher, int mac, void* ukey, int ukey_size, user_combo(user_ctx, text, ctext, sizes[i], digest); counted += sizes[i]; } while(benchmark_must_finish==0); - + ret = stop_benchmark(&bst, &elapsed); if (ret < 0) { ret = -1; goto finish; } - + t2 = (double)counted/(double)elapsed; - + #ifdef DEBUG printf("%d: kernel: %.4f bytes/msec, user: %.4f bytes/msec\n", sizes[i], t1, t2); #endif @@ -157,7 +157,7 @@ int aead_test(int cipher, int mac, void* ukey, int ukey_size, goto finish; } } - + ret = -1; finish: aead_ctx_deinit(&ctx); diff --git a/lib/hash.c b/lib/hash.c index a90e226..386fd7e 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -46,7 +46,7 @@ int hash_ctx_init(struct cryptodev_ctx* ctx, int hash, int cfd) return 0; } -void hash_ctx_deinit(struct cryptodev_ctx* ctx) +void hash_ctx_deinit(struct cryptodev_ctx* ctx) { if (ioctl(ctx->cfd, CIOCFSESSION, &ctx->sess.ses)) { perror("ioctl(CIOCFSESSION)"); @@ -57,7 +57,7 @@ int hash(struct cryptodev_ctx* ctx, const void* text, size_t size, void* digest) { struct crypt_op cryp; - + memset(&cryp, 0, sizeof(cryp)); /* Encrypt data.in to data.encrypted */ @@ -95,7 +95,7 @@ int hash_test(int algo, void (*user_hash)(void* text, int size, void* res)) } hash_ctx_init(&ctx, algo, cfd); - + for (i=0;i<sizeof(sizes)/sizeof(sizes[0]);i++) { counted = 0; ret = start_benchmark(&bst); @@ -108,7 +108,7 @@ int hash_test(int algo, void (*user_hash)(void* text, int size, void* res)) hash(&ctx, text, sizes[i], digest); counted += sizes[i]; } while(benchmark_must_finish==0); - + ret = stop_benchmark(&bst, &elapsed); if (ret < 0) { ret = -1; @@ -129,15 +129,15 @@ int hash_test(int algo, void (*user_hash)(void* text, int size, void* res)) user_hash(text, sizes[i], digest); counted += sizes[i]; } while(benchmark_must_finish==0); - + ret = stop_benchmark(&bst, &elapsed); if (ret < 0) { ret = -1; goto finish; } - + t2 = (double)counted/(double)elapsed; - + if (t1 > t2) { ret = sizes[i]; goto finish; @@ -146,7 +146,7 @@ int hash_test(int algo, void (*user_hash)(void* text, int size, void* res)) printf("%d: kernel: %.4f bytes/msec, user: %.4f bytes/msec\n", sizes[i], t1, t2); #endif } - + ret = -1; finish: hash_ctx_deinit(&ctx); diff --git a/lib/hash.h b/lib/hash.h index 1883bea..7c32cea 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -14,7 +14,7 @@ void hash_ctx_deinit(struct cryptodev_ctx* ctx); int hash(struct cryptodev_ctx* ctx, const void* text, size_t size, void* digest); int hash_test(int algo, void (*user_hash)(void* text, int size, void* res)); -int aead_test(int cipher, int mac, void* ukey, int ukey_size, +int aead_test(int cipher, int mac, void* ukey, int ukey_size, void* user_ctx, void (*user_combo)(void* user_ctx, void* plaintext, void* ciphertext, int size, void* res)); #endif diff --git a/lib/main.c b/lib/main.c index 49ca05b..443779a 100644 --- a/lib/main.c +++ b/lib/main.c @@ -19,10 +19,10 @@ int ret; ret = get_sha1_threshold(); if (ret > 0) printf("SHA1 in kernel outperforms user-space after %d input bytes\n", ret); - + ret = get_aes_sha1_threshold(); if (ret > 0) printf("AES-SHA1 in kernel outperforms user-space after %d input bytes\n", ret); - + return 0; } diff --git a/lib/threshold.c b/lib/threshold.c index f1215a3..b002d58 100644 --- a/lib/threshold.c +++ b/lib/threshold.c @@ -16,9 +16,9 @@ void sha_hash(void* text, int size, void* digest) SHA_CTX ctx; SHA_Init(&ctx); - + SHA_Update(&ctx, text, size); - + SHA_Final(digest, &ctx); } @@ -31,9 +31,9 @@ unsigned int rlen = 20; HMAC_CTX_init(&hctx); HMAC_Init_ex(&hctx, iv, 16, EVP_sha1(), NULL); - + HMAC_Update(&hctx, plaintext, size); - + HMAC_Final(&hctx, tag, &rlen); HMAC_CTX_cleanup(&hctx); @@ -52,7 +52,7 @@ uint8_t ukey[16]; ENGINE_load_builtin_engines(); ENGINE_register_all_complete(); - + memset(ukey, 0xaf, sizeof(ukey)); AES_set_encrypt_key(ukey, 16*8, &key); diff --git a/main.c b/main.c index bc54e47..fe6d390 100644 --- a/main.c +++ b/main.c @@ -127,7 +127,7 @@ __crypto_run_std(struct csession *ses_ptr, struct crypt_op *cop) size_t current_len = nbytes > bufsize ? bufsize : nbytes; if (unlikely(copy_from_user(data, src, current_len))) { - dprintk(1, KERN_ERR, "Error copying %d bytes from user address %p.\n", (int)current_len, src); + dprintk(1, KERN_ERR, "Error copying %d bytes from user address %p.\n", (int)current_len, src); ret = -EFAULT; break; } @@ -137,13 +137,13 @@ __crypto_run_std(struct csession *ses_ptr, struct crypt_op *cop) ret = hash_n_crypt(ses_ptr, cop, &sg, &sg, current_len); if (unlikely(ret)) { - dprintk(1, KERN_ERR, "hash_n_crypt failed.\n"); + dprintk(1, KERN_ERR, "hash_n_crypt failed.\n"); break; } if (ses_ptr->cdata.init != 0) { if (unlikely(copy_to_user(dst, data, current_len))) { - dprintk(1, KERN_ERR, "could not copy to user.\n"); + dprintk(1, KERN_ERR, "could not copy to user.\n"); ret = -EFAULT; break; } @@ -168,7 +168,7 @@ __crypto_run_zc(struct csession *ses_ptr, struct kernel_crypt_op *kcop) struct crypt_op *cop = &kcop->cop; int ret = 0; - ret = get_userbuf(ses_ptr, cop->src, cop->len, cop->dst, cop->len, + ret = get_userbuf(ses_ptr, cop->src, cop->len, cop->dst, cop->len, kcop->task, kcop->mm, &src_sg, &dst_sg); if (unlikely(ret)) { dprintk(1, KERN_ERR, "Error getting user pages. " diff --git a/zc.c b/zc.c index c9e6245..773dfb4 100644 --- a/zc.c +++ b/zc.c @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ @@ -38,7 +38,7 @@ #include "zc.h" #include "version.h" -/* Helper functions to assist zero copy. +/* Helper functions to assist zero copy. * This needs to be redesigned and moved out of the session. --nmav */ @@ -108,17 +108,17 @@ int adjust_sg_array(struct csession * ses, int pagecount) void release_user_pages(struct csession *ses) { -unsigned int i; + unsigned int i; for (i=0;i<ses->used_pages;i++) { if (!PageReserved(ses->pages[i])) SetPageDirty(ses->pages[i]); - - if (ses->readonly_pages == 0) - flush_dcache_page(ses->pages[i]); - else - ses->readonly_pages--; - + + if (ses->readonly_pages == 0) + flush_dcache_page(ses->pages[i]); + else + ses->readonly_pages--; + page_cache_release(ses->pages[i]); } ses->used_pages = 0; @@ -131,7 +131,7 @@ int get_userbuf(struct csession *ses, void* __user src, unsigned int src_len, void* __user dst, unsigned int dst_len, struct task_struct *task, struct mm_struct *mm, - struct scatterlist **src_sg, + struct scatterlist **src_sg, struct scatterlist **dst_sg) { int src_pagecount, dst_pagecount; @@ -182,7 +182,7 @@ int get_userbuf(struct csession *ses, else { const unsigned int readonly_pages = ses->readonly_pages; const unsigned int writable_pages = ses->used_pages - readonly_pages; - + if(likely(src)) { rc = __get_userbuf(src, src_len, 0, readonly_pages, ses->pages, ses->sg, task, mm); @@ -196,8 +196,8 @@ int get_userbuf(struct csession *ses, else { *src_sg = NULL; // no input } - - if(likely(dst)) { + + if(likely(dst)) { struct page **dst_pages = ses->pages + readonly_pages; *dst_sg = ses->sg + readonly_pages; diff --git a/zc.h b/zc.h index a98e60d..b52616e 100644 --- a/zc.h +++ b/zc.h @@ -13,7 +13,7 @@ int get_userbuf(struct csession *ses, void* __user src, unsigned int src_len, void* __user dst, unsigned int dst_len, struct task_struct *task, struct mm_struct *mm, - struct scatterlist **src_sg, + struct scatterlist **src_sg, struct scatterlist **dst_sg); /* buflen ? (last page - first page + 1) : 0 */ -- 1.7.8.6 _______________________________________________ Cryptodev-linux-devel mailing list Cryptodev-linux-devel@gna.org https://mail.gna.org/listinfo/cryptodev-linux-devel