X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=seed.h;h=78d7d59dcb56237d3ac8656bffec232af8cc4577;hb=dbbf324199b1aa27be910e00e1aad5e991d70e98;hp=330944d419679bf6cf3919bc9c63b6c7fa1777f7;hpb=96ebafd201c9e8441c7677577b24aa402c1defc6;p=avr-crypto-lib.git diff --git a/seed.h b/seed.h index 330944d..78d7d59 100644 --- a/seed.h +++ b/seed.h @@ -1,6 +1,6 @@ /* seed.h */ /* - 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 @@ -29,15 +29,53 @@ #define SEED_H_ #include - +/** \typedef seed_ctx_t + * \brief SEED context + * + * A variable of this type may hold the key material for the SEED cipher. + * This context is regulary generated by the + * void seed_init(const void * key, seed_ctx_t * ctx) function. + */ typedef struct{ uint32_t k[4]; } seed_ctx_t; /******************************************************************************/ -void seed_init(seed_ctx_t * ctx, uint8_t * key); -void seed_encrypt(seed_ctx_t * ctx, void * buffer); -void seed_decrypt(seed_ctx_t * ctx, void * buffer); +/** \fn void seed_init(const void * key, seed_ctx_t * ctx) + * \brief initializes context for SEED operation + * + * This function copys the key material into a context variable. + * + * \param key pointer to the key material (128 bit = 16 bytes) + * \param ctx pointer to the context (seed_ctx_t) + */ +void seed_init(const void * key, seed_ctx_t * ctx); + +/** \fn void seed_enc(void * buffer,const seed_ctx_t * ctx) + * \brief encrypt a block with SEED + * + * This function encrypts a block of 64 bits (8 bytes) with the SEED algorithm. + * The round keys are computed on demand, so the context is modifyed while + * encrypting but the original stated is restored when the function exits. + * + * \param buffer pointer to the block (64 bit = 8 byte) which will be encrypted + * \param ctx pointer to the key material (seed_ctx_t) + */ +void seed_enc(void * buffer, const seed_ctx_t * ctx); + + +/** \fn void seed_dec(void * buffer, const seed_ctx_t * ctx) + * \brief decrypt a block with SEED + * + * This function decrypts a block of 64 bits (8 bytes) with the SEED algorithm. + * The round keys are computed on demand, so the context is modifyed while + * decrypting but the original stated is restored when the function exits. + * + * \param buffer pointer to the block (64 bit = 8 byte) which will be decrypted + * \param ctx pointer to the key material (seed_ctx_t) + */ +void seed_dec(void * buffer, const seed_ctx_t * ctx); + #endif /*SEED_H_*/