]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - serpent.c
forgotten files
[avr-crypto-lib.git] / serpent.c
index 4960664669ec1fe8a4647604b3ac2233434a71fc..40ccecd4ac58f726cea41b8bc90d8b35a2b70ac1 100644 (file)
--- a/serpent.c
+++ b/serpent.c
@@ -1,6 +1,6 @@
 /* serpent.c */
 /*
-    This file is part of the Crypto-avr-lib/microcrypt-lib.
+    This file is part of the AVR-Crypto-Lib.
     Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
 
     This program is free software: you can redistribute it and/or modify
@@ -47,8 +47,6 @@ uint32_t rotr32(uint32_t a, uint8_t n){
 #define X2 (((uint32_t*)b)[2])
 #define X3 (((uint32_t*)b)[3])
 
-void serpent_lt(uint8_t *b);
-/*
 static void serpent_lt(uint8_t *b){
        X0 = rotl32(X0, 13);
        X2 = rotl32(X2,  3);
@@ -61,11 +59,7 @@ static void serpent_lt(uint8_t *b){
        X0 = rotl32(X0, 5);
        X2 = rotr32(X2, 10);
 }
-*/
-
-static void serpent_inv_lt(uint8_t *b);
 
-/*
 static void serpent_inv_lt(uint8_t *b){
        X2 = rotl32(X2, 10);
        X0 = rotr32(X0, 5);
@@ -78,10 +72,7 @@ static void serpent_inv_lt(uint8_t *b){
        X2 = rotr32(X2,  3);
        X0 = rotr32(X0, 13);
 }
-*/
 
-uint32_t serpent_gen_w(uint32_t * b, uint8_t i);
-/*
 #define GOLDEN_RATIO 0x9e3779b9l
 
 static uint32_t serpent_gen_w(uint32_t * b, uint8_t i){
@@ -90,15 +81,15 @@ static uint32_t serpent_gen_w(uint32_t * b, uint8_t i){
        ret = rotl32(ret, 11);
        return ret;
 } 
-*/
-void serpent_init(const void* key, uint16_t keysize, serpent_ctx_t* ctx){
+
+void serpent_init(const void* key, uint16_t keysize_b, serpent_ctx_t* ctx){
        uint32_t buffer[8];
        uint8_t i,j;
-       if(keysize<256){
+       if(keysize_b<256){
                /* keysize is less than 256 bit, padding needed */
                memset(buffer, 0, 32);
-               memcpy(buffer, key, (keysize+7)/8);
-               ((uint8_t*)buffer)[keysize/8] |= 1<<(keysize%8);
+               memcpy(buffer, key, (keysize_b+7)/8);
+               ((uint8_t*)buffer)[keysize_b/8] |= 1<<(keysize_b%8);
        } else {
                /* keysize is 256 bit */
                memcpy(buffer, key, 32); 
@@ -115,7 +106,6 @@ void serpent_init(const void* key, uint16_t keysize, serpent_ctx_t* ctx){
        }
 }
 
-
 void serpent_enc(void* buffer, const serpent_ctx_t* ctx){
        uint8_t i;
        for(i=0; i<31; ++i){
@@ -148,4 +138,3 @@ void serpent_dec(void* buffer, const serpent_ctx_t* ctx){
 
 
 
-