Advertisement
captmicro

Untitled

Mar 18th, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #ifndef _crypto_h_
  2. #define _crypto_h_
  3.  
  4. #include "type.h"
  5. #include "def.h"
  6.  
  7. /* LFSR */
  8. typedef struct {
  9. uint32 state;
  10. uint8 taps[32];
  11. } CRYPTO_LFSR;
  12. void cyrpto_LFSRinit(CRYPTO_LFSR *LFSR, uint32 state, uint8 *taps);
  13. uint32 crypto_LFSRshift(CRYPTO_LFSR *LFSR);
  14.  
  15. /* PRNG */
  16. uint32 crypto_rand(uint32 seed);
  17.  
  18. /* [STREAM] RC4 */
  19. typedef struct {
  20. uint8 S[256];
  21. } CRYPTO_RC4;
  22. void crypto_RC4init(CRYPTO_RC4 *rc4, uint8 *key, uint32 keysz);
  23. uint8 crypto_RC4byte(CRYPTO_RC4 *rc4);
  24. void crypto_RC4inplace(CRYPTO_RC4 *rc4, uint8 *data, uint32 sz);
  25. void crypto_RC4encrypt(uint8 *key, uint32 keysz, uint8 *data, uint32 datasz);
  26.  
  27. /* [BLOCK] XTEA */
  28. void crypto_XTEAencrypt(uint32 rounds, uint32 data[2], uint32 key[4]);
  29. void crypto_XTEAdecrypt(uint32 rounds, uint32 data[2], uint32 key[4]);
  30.  
  31. /* [BLOCK] SKIPJACK */
  32. uint16 crypto_SKIPJACK_G(uint16 g, uint8 k, uint8 *key);
  33. uint16 crypto_SKIPJACK_Gi(uint16 g, uint8 k, uint8 *key);
  34. void crypto_SKIPJACKencrypt(uint16 data[4], uint8 key[5]);
  35. void crypto_SKIPJACKdecrypt(uint16 data[4], uint8 key[5]);
  36.  
  37. /* [KEY XCNG] DIFFIE-HELLMAN */
  38. typedef struct {
  39. uint32 p, g;
  40. uint32 a, A;
  41. uint32 secret;
  42. } crypto_DHKE;
  43. void crypto_DHKEinit(crypto_DHKE *DHKE, uint32 p, uint32 g);
  44. void crypto_DHKEcomputeshared(crypto_DHKE *DHKE, uint32 B);
  45.  
  46. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement