dh.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* dh.h
  4. *
  5. * Copyright (C) 2006-2014 wolfSSL Inc.
  6. *
  7. * This file is part of CyaSSL.
  8. *
  9. * CyaSSL is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * CyaSSL is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef CTAO_CRYPT_DH_H
  24. #define CTAO_CRYPT_DH_H
  25. #include <stdint.h>
  26. #ifndef word32
  27. typedef uint32_t word32;
  28. #endif
  29. #ifndef byte
  30. typedef uint8_t byte;
  31. #endif
  32. #define BIT_SIZE 8
  33. #include "integer.h"
  34. /* Diffie-Hellman Key */
  35. typedef struct DhKey {
  36. mp_int p, g; /* group parameters */
  37. } DhKey;
  38. void InitDhKey(DhKey *key);
  39. void FreeDhKey(DhKey *key);
  40. int DhGenerateKeyPair(DhKey *key, byte *priv,
  41. word32 *privSz, byte *pub, word32 *pubSz);
  42. int DhAgree(DhKey *key, byte *agree, word32 *agreeSz,
  43. const byte *priv, word32 privSz, const byte *otherPub,
  44. word32 pubSz);
  45. int DhSetKey(DhKey *key, const byte *p, word32 pSz, const byte *g,
  46. word32 gSz);
  47. #endif /* CTAO_CRYPT_DH_H */