dsa.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* dsa.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de)
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef DSA_H_
  17. #define DSA_H_
  18. #include <stdint.h>
  19. #include <crypto/hfal-basic.h>
  20. #include <crypto/bigint.h>
  21. typedef struct{
  22. bigint_t p;
  23. bigint_t q;
  24. bigint_t g;
  25. } dsa_domainparameters_t;
  26. typedef bigint_t dsa_pubkey_t;
  27. typedef bigint_t dsa_privkey_t;
  28. typedef struct{
  29. bigint_t r;
  30. bigint_t s;
  31. } dsa_signature_t;
  32. typedef struct{
  33. dsa_privkey_t priv;
  34. dsa_pubkey_t pub;
  35. dsa_domainparameters_t domain;
  36. } dsa_ctx_t;
  37. #define DSA_SIGNATURE_OK 1
  38. #define DSA_SIGNATURE_FAIL 0
  39. uint8_t dsa_sign_bigint(dsa_signature_t* s, const bigint_t* m,
  40. const dsa_ctx_t* ctx, const bigint_t* k);
  41. uint8_t dsa_sign_message(dsa_signature_t* s, const void* m, uint16_t m_len_b,
  42. const hfdesc_t* hash_desc, const dsa_ctx_t* ctx,
  43. uint8_t(*rand_in)(void));
  44. uint8_t dsa_verify_bigint(const dsa_signature_t* s, const bigint_t* m,
  45. const dsa_ctx_t* ctx);
  46. uint8_t dsa_verify_message(const dsa_signature_t* s, const void* m, uint16_t m_len_b,
  47. const hfdesc_t* hash_desc, const dsa_ctx_t* ctx);
  48. #endif /* DSA_H_ */