digsig.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) 2011 Nokia Corporation
  3. * Copyright (C) 2011 Intel Corporation
  4. *
  5. * Author:
  6. * Dmitry Kasatkin <dmitry.kasatkin@nokia.com>
  7. * <dmitry.kasatkin@intel.com>
  8. *
  9. * This program 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, version 2 of the License.
  12. *
  13. */
  14. #ifndef _DIGSIG_H
  15. #define _DIGSIG_H
  16. #include <linux/key.h>
  17. enum pubkey_algo {
  18. PUBKEY_ALGO_RSA,
  19. PUBKEY_ALGO_MAX,
  20. };
  21. enum digest_algo {
  22. DIGEST_ALGO_SHA1,
  23. DIGEST_ALGO_SHA256,
  24. DIGEST_ALGO_MAX
  25. };
  26. struct pubkey_hdr {
  27. uint8_t version; /* key format version */
  28. uint32_t timestamp; /* key made, always 0 for now */
  29. uint8_t algo;
  30. uint8_t nmpi;
  31. char mpi[0];
  32. } __packed;
  33. struct signature_hdr {
  34. uint8_t version; /* signature format version */
  35. uint32_t timestamp; /* signature made */
  36. uint8_t algo;
  37. uint8_t hash;
  38. uint8_t keyid[8];
  39. uint8_t nmpi;
  40. char mpi[0];
  41. } __packed;
  42. #if defined(CONFIG_SIGNATURE) || defined(CONFIG_SIGNATURE_MODULE)
  43. int digsig_verify(struct key *keyring, const char *sig, int siglen,
  44. const char *digest, int digestlen);
  45. #else
  46. static inline int digsig_verify(struct key *keyring, const char *sig,
  47. int siglen, const char *digest, int digestlen)
  48. {
  49. return -EOPNOTSUPP;
  50. }
  51. #endif /* CONFIG_SIGNATURE */
  52. #endif /* _DIGSIG_H */