]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - cast5.c
some minor changes to performance testing code
[avr-crypto-lib.git] / cast5.c
diff --git a/cast5.c b/cast5.c
index 34c5a78e3dc5a674ad3afabb0cb15293391ec6bb..204fe30dcc1d74c593fa9e731f7aa2b3d1c0ec03 100644 (file)
--- a/cast5.c
+++ b/cast5.c
@@ -102,7 +102,9 @@ void cast5_init(cast5_ctx_t* s, uint8_t* key, uint8_t keylength){
        s->shortkey = (keylength<=80);
        /* littel endian only! */
        memset(&(x[0]), 0 ,16); /* set x to zero */
-       memcpy(&(x[0]), key, keylength/8);
+       if(keylength > 128)
+               keylength=128;
+       memcpy(&(x[0]), key, (keylength+7)/8);
        
 
        /* todo: merge a and b and compress the whole stuff */