From: bg Date: Fri, 9 Jan 2009 13:52:49 +0000 (+0000) Subject: some mor ciphers for the blockcipher abstraction layer X-Git-Url: https://git.cryptolib.org/?a=commitdiff_plain;h=1a1a9f56318298d8ec87df9f7e78da68732f0d48;p=avr-crypto-lib.git some mor ciphers for the blockcipher abstraction layer --- diff --git a/bcal-basic.c b/bcal-basic.c index bb97b9f..6fd344d 100644 --- a/bcal-basic.c +++ b/bcal-basic.c @@ -63,35 +63,24 @@ void bcal_cipher_free(bcgen_ctx_t* ctx){ } void bcal_cipher_enc(void* block, const bcgen_ctx_t* ctx){ - uint8_t flags; bc_enc_fpt enc_fpt; - flags = pgm_read_byte(ctx->desc_ptr->flags); enc_fpt.encvoid = (void_fpt)pgm_read_word(ctx->desc_ptr->enc.encvoid); if(!enc_fpt.encvoid){ /* very bad error, no enciphering function specified */ return; } - if((flags&BC_ENC_TYPE)==BC_ENC_TYPE_1){ - enc_fpt.enc1(block, ctx->ctx); - }else{ - enc_fpt.enc2(block, block, ctx->ctx); - } + enc_fpt.enc1(block, ctx->ctx); + } void bcal_cipher_dec(void* block, const bcgen_ctx_t* ctx){ - uint8_t flags; bc_dec_fpt dec_fpt; - flags = pgm_read_byte(ctx->desc_ptr->flags); dec_fpt.decvoid = (void_fpt)pgm_read_word(ctx->desc_ptr->dec.decvoid); if(!dec_fpt.decvoid){ /* very bad error, no deciphering function specified */ return; } - if((flags&BC_DEC_TYPE)==BC_DEC_TYPE_1){ - dec_fpt.dec1(block, ctx->ctx); - }else{ - dec_fpt.dec2(block, block, ctx->ctx); - } + dec_fpt.dec1(block, ctx->ctx); } diff --git a/bcal_aes128.c b/bcal_aes128.c new file mode 100644 index 0000000..48b9216 --- /dev/null +++ b/bcal_aes128.c @@ -0,0 +1,55 @@ +/* bcal_aes128.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_aes128.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-08 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "aes.h" +#include "aes128_enc.h" +#include "aes128_dec.h" +#include "aes_keyschedule.h" +#include "keysize_descriptor.h" + +const char aes128_str[] PROGMEM = "AES-128"; + +const uint8_t aes128_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128), + KS_TYPE_TERMINATOR }; + +const bcdesc_t aes128_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_2, + aes128_str, + sizeof(aes128_ctx_t), + 128, + {(void_fpt)aes_init}, + {(void_fpt)aes128_enc}, + {(void_fpt)aes128_dec}, + (bc_free_fpt)NULL, + aes128_keysize_desc +}; + + diff --git a/bcal_aes128.h b/bcal_aes128.h new file mode 100644 index 0000000..035b252 --- /dev/null +++ b/bcal_aes128.h @@ -0,0 +1,35 @@ +/* bcal_aes128.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_aes128.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-08 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "aes.h" +#include "aes128_enc.h" +#include "aes128_dec.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t aes128_desc; diff --git a/bcal_aes192.c b/bcal_aes192.c new file mode 100644 index 0000000..47d4cb7 --- /dev/null +++ b/bcal_aes192.c @@ -0,0 +1,55 @@ +/* bcal_aes192.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_aes192.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-08 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "aes.h" +#include "aes192_enc.h" +#include "aes192_dec.h" +#include "aes_keyschedule.h" +#include "keysize_descriptor.h" + +const char aes192_str[] PROGMEM = "AES-192"; + +const uint8_t aes192_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(192), + KS_TYPE_TERMINATOR }; + +const bcdesc_t aes192_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_2, + aes192_str, + sizeof(aes192_ctx_t), + 128, + {(void_fpt)aes_init}, + {(void_fpt)aes192_enc}, + {(void_fpt)aes192_dec}, + (bc_free_fpt)NULL, + aes192_keysize_desc +}; + + diff --git a/bcal_aes192.h b/bcal_aes192.h new file mode 100644 index 0000000..d669aed --- /dev/null +++ b/bcal_aes192.h @@ -0,0 +1,35 @@ +/* bcal_aes192.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_aes192.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-08 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "aes.h" +#include "aes192_enc.h" +#include "aes192_dec.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t aes192_desc; diff --git a/bcal_aes256.c b/bcal_aes256.c new file mode 100644 index 0000000..a611700 --- /dev/null +++ b/bcal_aes256.c @@ -0,0 +1,55 @@ +/* bcal_aes256.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_aes256.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-08 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "aes.h" +#include "aes256_enc.h" +#include "aes256_dec.h" +#include "aes_keyschedule.h" +#include "keysize_descriptor.h" + +const char aes256_str[] PROGMEM = "AES-256"; + +const uint8_t aes256_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(256), + KS_TYPE_TERMINATOR }; + +const bcdesc_t aes256_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_2, + aes256_str, + sizeof(aes256_ctx_t), + 128, + {(void_fpt)aes_init}, + {(void_fpt)aes256_enc}, + {(void_fpt)aes256_dec}, + (bc_free_fpt)NULL, + aes256_keysize_desc +}; + + diff --git a/bcal_aes256.h b/bcal_aes256.h new file mode 100644 index 0000000..cc67967 --- /dev/null +++ b/bcal_aes256.h @@ -0,0 +1,35 @@ +/* bcal_aes256.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_aes256.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-08 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "aes.h" +#include "aes256_enc.h" +#include "aes256_dec.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t aes256_desc; diff --git a/bcal_camellia128.c b/bcal_camellia128.c new file mode 100644 index 0000000..b2efb25 --- /dev/null +++ b/bcal_camellia128.c @@ -0,0 +1,52 @@ +/* bcal_camellia128.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_camellia128.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "camellia.h" +#include "keysize_descriptor.h" + +const char camellia128_str[] PROGMEM = "Camellia-128"; + +const uint8_t camellia128_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128), + KS_TYPE_TERMINATOR }; + +const bcdesc_t camellia128_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_2, + camellia128_str, + sizeof(camellia128_ctx_t), + 128, + {(void_fpt)camellia128_init}, + {(void_fpt)camellia128_enc}, + {(void_fpt)camellia128_dec}, + (bc_free_fpt)NULL, + camellia128_keysize_desc +}; + + diff --git a/bcal_camellia128.h b/bcal_camellia128.h new file mode 100644 index 0000000..05c5751 --- /dev/null +++ b/bcal_camellia128.h @@ -0,0 +1,33 @@ +/* bcal_camellia128.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_camellia128.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "camellia.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t camellia128_desc; diff --git a/bcal_cast5.c b/bcal_cast5.c new file mode 100644 index 0000000..b84bd41 --- /dev/null +++ b/bcal_cast5.c @@ -0,0 +1,52 @@ +/* bcal_cast5.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_cast5.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "cast5.h" +#include "keysize_descriptor.h" + +const char cast5_str[] PROGMEM = "CAST5"; + +const uint8_t cast5_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(0), KS_INT(128), + KS_TYPE_TERMINATOR }; + +const bcdesc_t cast5_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_2, + cast5_str, + sizeof(cast5_ctx_t), + 128, + {(void_fpt)cast5_init}, + {(void_fpt)cast5_enc}, + {(void_fpt)cast5_dec}, + (bc_free_fpt)NULL, + cast5_keysize_desc +}; + + diff --git a/bcal_cast5.h b/bcal_cast5.h new file mode 100644 index 0000000..97c30f6 --- /dev/null +++ b/bcal_cast5.h @@ -0,0 +1,33 @@ +/* bcal_cast5.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_cast5.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "cast5.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t cast5_desc; diff --git a/bcal_des.c b/bcal_des.c new file mode 100644 index 0000000..8f35bc2 --- /dev/null +++ b/bcal_des.c @@ -0,0 +1,61 @@ +/* bcal_des.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_des.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "des.h" +#include "keysize_descriptor.h" + +const char des_str[] PROGMEM = "DES"; + +const uint8_t des_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(64), + KS_TYPE_TERMINATOR }; +static +void des_dummy_enc(void* block, coid* key){ + des_enc(block, block, key); +} + +static +void des_dummy_dec(void* block, coid* key){ + des_dec(block, block, key); +} + +const bcdesc_t des_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_1, + des_str, + 8, + 128, + {(void_fpt)NULL}, + {(void_fpt)des_dummy_enc}, + {(void_fpt)des_dummy_dec}, + (bc_free_fpt)NULL, + des_keysize_desc +}; + + diff --git a/bcal_des.h b/bcal_des.h new file mode 100644 index 0000000..d5eebc8 --- /dev/null +++ b/bcal_des.h @@ -0,0 +1,33 @@ +/* bcal_des.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_des.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "des.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t des_desc; diff --git a/bcal_noekeon.c b/bcal_noekeon.c index b1a3485..c58bdcb 100644 --- a/bcal_noekeon.c +++ b/bcal_noekeon.c @@ -9,7 +9,7 @@ const char noekeon_direct_str[] PROGMEM = "Noekeon-Direct"; const char noekeon_indirect_str[] PROGMEM = "Noekeon-Indirect"; -const uint8_t noekeon_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, 128, +const uint8_t noekeon_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128), KS_TYPE_TERMINATOR }; const bcdesc_t noekeon_direct_desc PROGMEM = { @@ -18,10 +18,10 @@ const bcdesc_t noekeon_direct_desc PROGMEM = { noekeon_direct_str, 16, 128, - (void_fpt)NULL, - (void_fpt)noekeon_enc, - (void_fpt)noekeon_dec, - (void_fpt)NULL, + {(void_fpt)NULL}, + {(void_fpt)noekeon_enc}, + {(void_fpt)noekeon_dec}, + (bc_free_fpt)NULL, noekeon_keysize_desc }; @@ -31,10 +31,10 @@ const bcdesc_t noekeon_indirect_desc PROGMEM = { noekeon_indirect_str, 16, 128, - (void_fpt)noekeon_init, - (void_fpt)noekeon_enc, - (void_fpt)noekeon_dec, - (void_fpt)NULL, + {(void_fpt)noekeon_init}, + {(void_fpt)noekeon_enc}, + {(void_fpt)noekeon_dec}, + (bc_free_fpt)NULL, noekeon_keysize_desc }; diff --git a/bcal_present.c b/bcal_present.c new file mode 100644 index 0000000..c22f2f9 --- /dev/null +++ b/bcal_present.c @@ -0,0 +1,52 @@ +/* bcal_present.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_present.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "present.h" +#include "keysize_descriptor.h" + +const char present_str[] PROGMEM = "Present"; + +const uint8_t present_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(80), + KS_TYPE_TERMINATOR }; + +const bcdesc_t present_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_1, + present_str, + sizeof(present_ctx_t), + 64, + {(void_fpt)present_init}, + {(void_fpt)present_enc}, + {(void_fpt)present_dec}, + (bc_free_fpt)NULL, + present_keysize_desc +}; + + diff --git a/bcal_present.h b/bcal_present.h new file mode 100644 index 0000000..0f095a2 --- /dev/null +++ b/bcal_present.h @@ -0,0 +1,33 @@ +/* bcal_present.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_present.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "present.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t present_desc; diff --git a/bcal_rc5.c b/bcal_rc5.c new file mode 100644 index 0000000..a0b4c84 --- /dev/null +++ b/bcal_rc5.c @@ -0,0 +1,59 @@ +/* bcal_rc5.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_rc5.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "rc5.h" +#include "keysize_descriptor.h" + +#define RC5_ROUNDS 12 + +const char rc5_str[] PROGMEM = "RC5"; + +const uint8_t rc5_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(1), KS_INT(2040), + KS_TYPE_TERMINATOR }; + +static +void rc5_dummy_init(void* key, uint16_t keysize_b, void* ctx){ + rc5_init(key, keysize_b, RC5_ROUNDS, ctx); +} + +const bcdesc_t rc5_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_4, + rc5_str, + sizeof(rc5_ctx_t), + 128, + {(void_fpt)rc5_dummy_init}, + {(void_fpt)rc5_enc}, + {(void_fpt)rc5_dec}, + (bc_free_fpt)rc5_free, + rc5_keysize_desc +}; + + diff --git a/bcal_rc5.h b/bcal_rc5.h new file mode 100644 index 0000000..8c7cc26 --- /dev/null +++ b/bcal_rc5.h @@ -0,0 +1,33 @@ +/* bcal_rc5.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_rc5.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "rc5.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t rc5_desc; diff --git a/bcal_rc6.c b/bcal_rc6.c new file mode 100644 index 0000000..ac73c68 --- /dev/null +++ b/bcal_rc6.c @@ -0,0 +1,52 @@ +/* bcal_rc6.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_rc6.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "rc6.h" +#include "keysize_descriptor.h" + +const char rc6_str[] PROGMEM = "RC6"; + +const uint8_t rc6_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(1), KS_INT(2040), + KS_TYPE_TERMINATOR }; + +const bcdesc_t rc6_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_2, + rc6_str, + sizeof(rc6_ctx_t), + 128, + {(void_fpt)rc6_init}, + {(void_fpt)rc6_enc}, + {(void_fpt)rc6_dec}, + (bc_free_fpt)rc6_free, + rc6_keysize_desc +}; + + diff --git a/bcal_rc6.h b/bcal_rc6.h new file mode 100644 index 0000000..3915816 --- /dev/null +++ b/bcal_rc6.h @@ -0,0 +1,33 @@ +/* bcal_rc6.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_rc6.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "rc6.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t rc6_desc; diff --git a/bcal_seed.c b/bcal_seed.c new file mode 100644 index 0000000..2a61164 --- /dev/null +++ b/bcal_seed.c @@ -0,0 +1,52 @@ +/* bcal_seed.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_seed.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "seed.h" +#include "keysize_descriptor.h" + +const char seed_str[] PROGMEM = "SEED"; + +const uint8_t seed_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128), + KS_TYPE_TERMINATOR }; + +const bcdesc_t seed_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_1, + seed_str, + sizeof(seed_ctx_t), + 128, + {(void_fpt)seed_init}, + {(void_fpt)seed_enc}, + {(void_fpt)seed_dec}, + (bc_free_fpt)NULL, + seed_keysize_desc +}; + + diff --git a/bcal_seed.h b/bcal_seed.h new file mode 100644 index 0000000..0457d01 --- /dev/null +++ b/bcal_seed.h @@ -0,0 +1,33 @@ +/* bcal_seed.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_seed.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "seed.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t seed_desc; diff --git a/bcal_serpent.c b/bcal_serpent.c new file mode 100644 index 0000000..760f208 --- /dev/null +++ b/bcal_serpent.c @@ -0,0 +1,52 @@ +/* bcal_serpent.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_serpent.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "serpent.h" +#include "keysize_descriptor.h" + +const char serpent_str[] PROGMEM = "serpent"; + +const uint8_t serpent_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(1), KS_INT(256), + KS_TYPE_TERMINATOR }; + +const bcdesc_t serpent_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_2, + serpent_str, + sizeof(serpent_ctx_t), + 128, + {(void_fpt)serpent_init}, + {(void_fpt)serpent_enc}, + {(void_fpt)serpent_dec}, + (bc_free_fpt)NULL, + serpent_keysize_desc +}; + + diff --git a/bcal_serpent.h b/bcal_serpent.h new file mode 100644 index 0000000..65dcc15 --- /dev/null +++ b/bcal_serpent.h @@ -0,0 +1,33 @@ +/* bcal_serpent.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_serpent.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "serpent.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t serpent_desc; diff --git a/bcal_skipjack.c b/bcal_skipjack.c new file mode 100644 index 0000000..3ee0491 --- /dev/null +++ b/bcal_skipjack.c @@ -0,0 +1,52 @@ +/* bcal_skipjack.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_skipjack.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "skipjack.h" +#include "keysize_descriptor.h" + +const char skipjack_str[] PROGMEM = "Skipjack"; + +const uint8_t skipjack_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(80), + KS_TYPE_TERMINATOR }; + +const bcdesc_t skipjack_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_1, + skipjack_str, + 10, + 64, + {(void_fpt)NULL}, + {(void_fpt)skipjack_enc}, + {(void_fpt)skipjack_dec}, + (bc_free_fpt)NULL, + skipjack_keysize_desc +}; + + diff --git a/bcal_skipjack.h b/bcal_skipjack.h new file mode 100644 index 0000000..018064c --- /dev/null +++ b/bcal_skipjack.h @@ -0,0 +1,33 @@ +/* bcal_skipjack.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_skipjack.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "skipjack.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t skipjack_desc; diff --git a/bcal_tdes.c b/bcal_tdes.c new file mode 100644 index 0000000..68d1bac --- /dev/null +++ b/bcal_tdes.c @@ -0,0 +1,62 @@ +/* bcal_tdes.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_tdes.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "des.h" +#include "keysize_descriptor.h" + +const char tdes_str[] PROGMEM = "TDES"; + +const uint8_t tdes_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(192), + KS_TYPE_TERMINATOR }; + +static +void tdes_dummy_enc(void* block, void* key){ + tdes_enc(block, block, key); +} + +static +void tdes_dummy_dec(void* block, void* key){ + tdes_dec(block, block, key); +} + +const bcdesc_t tdes_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_1, + tdes_str, + 24, + 128, + {(void_fpt)NULL}, + {(void_fpt)tdes_dummy_enc}, + {(void_fpt)tdes_dummy_dec}, + (bc_free_fpt)NULL, + tdes_keysize_desc +}; + + diff --git a/bcal_tdes.h b/bcal_tdes.h new file mode 100644 index 0000000..84a47eb --- /dev/null +++ b/bcal_tdes.h @@ -0,0 +1,33 @@ +/* bcal_tdes.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_tdes.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "des.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t tdes_desc; diff --git a/bcal_xtea.c b/bcal_xtea.c new file mode 100644 index 0000000..51988ad --- /dev/null +++ b/bcal_xtea.c @@ -0,0 +1,62 @@ +/* bcal_xtea.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_xtea.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "xtea.h" +#include "keysize_descriptor.h" + +const char xtea_str[] PROGMEM = "XTEA"; + +const uint8_t xtea_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128), + KS_TYPE_TERMINATOR }; + +static +void xtea_dummy_enc(void* block, void* key){ + xtea_enc(block, block, key); +} + +static +void xtea_dummy_dec(void* block, void* key){ + xtea_dec(block, block, key); +} + +const bcdesc_t xtea_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_2, + xtea_str, + 16, + 64, + {(void_fpt)NULL}, + {(void_fpt)xtea_dummy_enc}, + {(void_fpt)xtea_dummy_dec}, + (bc_free_fpt)NULL, + xtea_keysize_desc +}; + + diff --git a/bcal_xtea.h b/bcal_xtea.h new file mode 100644 index 0000000..c6cb17d --- /dev/null +++ b/bcal_xtea.h @@ -0,0 +1,33 @@ +/* bcal_xtea.h */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * \file bcal_xtea.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2009-01-09 + * \license GPLv3 or later + * + */ + +#include +#include "blopckcipher_descriptor.h" +#include "xtea.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t xtea_desc; diff --git a/cast5.c b/cast5.c index 59f6dbd..4bed59e 100644 --- a/cast5.c +++ b/cast5.c @@ -130,7 +130,7 @@ void cast5_init_rM(uint8_t *klo, uint8_t *khi, uint8_t offset, uint8_t *src, boo -void cast5_init(const void* key, uint8_t keylength_b, cast5_ctx_t* s){ +void cast5_init(const void* key, uint16_t keylength_b, cast5_ctx_t* s){ /* we migth return if the key is valid and if setup was sucessfull */ uint32_t x[4], z[4]; #define BPX ((uint8_t*)&(x[0])) diff --git a/cast5.h b/cast5.h index 2b1d317..c33d805 100644 --- a/cast5.h +++ b/cast5.h @@ -16,20 +16,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* - * File: cast5.h - * Author: Daniel Otte - * Date: 2006-07-26 - * License: GPL - * Description: Implementation of the CAST5 (aka CAST-128) cipher algorithm as described in RFC 2144 - * - */ - /** * \file cast5.h * \author Daniel Otte * \date 2006-07-26 - * \license GPL + * \license GPLv3 or later * \brief Implementation of the CAST5 (aka CAST-128) cipher algorithm as described in RFC 2144 * */ @@ -74,7 +65,7 @@ typedef struct cast5_ctx_st{ * \param keylength_b length of the key in bits (maximum 128 bits) * \param s pointer to the context */ -void cast5_init(const void* key, uint8_t keylength_b, cast5_ctx_t* s); +void cast5_init(const void* key, uint16_t keylength_b, cast5_ctx_t* s); /** \fn void cast5_enc(void* block, const cast5_ctx_t *s); * \brief encrypt a block with the CAST-5 algorithm diff --git a/keysize_descriptor.h b/keysize_descriptor.h index 39a563e..ecb3761 100644 --- a/keysize_descriptor.h +++ b/keysize_descriptor.h @@ -35,6 +35,7 @@ #define KS_TYPE_RANGE 0x02 #define KS_TYPE_ARG_RANGE 0x03 +#define KS_INT(a) ((a)&0xFF), ((a)>>8) typedef struct{ /* keysize is valid if listed in items */ uint8_t n_items; /* number of items (value 0 is reserved) */