crypto_internal.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef CRYPTO_INTERNAL_H_
  2. #define CRYPTO_INTERNAL_H_
  3. #include <stdint.h>
  4. struct crypto_hmac_key {
  5. size_t len;
  6. uint8_t * key;
  7. };
  8. /**
  9. * crypto_keys_lookup_RSA(key):
  10. * Return the requested RSA key.
  11. */
  12. void * crypto_keys_lookup_RSA(int);
  13. /**
  14. * crypto_keys_lookup_HMAC(key):
  15. * Return the requested HMAC key.
  16. */
  17. struct crypto_hmac_key * crypto_keys_lookup_HMAC(int);
  18. /**
  19. * crypto_keys_server_import_root(void):
  20. * Import the public part of the server root key.
  21. */
  22. int crypto_keys_server_import_root(void);
  23. /**
  24. * crypto_keys_subr_import_RSA_priv(key, buf, buflen):
  25. * Import the specified RSA private key from the provided buffer.
  26. */
  27. int crypto_keys_subr_import_RSA_priv(void **, const uint8_t *, size_t);
  28. /**
  29. * crypto_keys_subr_import_RSA_pub(key, buf, buflen):
  30. * Import the specified RSA public key from the provided buffer.
  31. */
  32. int crypto_keys_subr_import_RSA_pub(void **, const uint8_t *, size_t);
  33. /**
  34. * crypto_keys_subr_import_HMAC(key, buf, buflen):
  35. * Import the specified HMAC key from the provided buffer.
  36. */
  37. int crypto_keys_subr_import_HMAC(struct crypto_hmac_key **, const uint8_t *,
  38. size_t);
  39. /**
  40. * crypto_keys_subr_export_RSA_priv(key, buf, buflen):
  41. * If buf != NULL, export the specified RSA private key. Return the key
  42. * length in bytes.
  43. */
  44. uint32_t crypto_keys_subr_export_RSA_priv(void *, uint8_t *, size_t);
  45. /**
  46. * crypto_keys_subr_export_RSA_pub(key, buf, buflen):
  47. * If buf != NULL, export the specified RSA public key. Return the key
  48. * length in bytes.
  49. */
  50. uint32_t crypto_keys_subr_export_RSA_pub(void *, uint8_t *, size_t);
  51. /**
  52. * crypto_keys_subr_export_HMAC(key, buf, buflen):
  53. * If buf != NULL, export the specified HMAC key. Return the key length
  54. * in bytes.
  55. */
  56. uint32_t crypto_keys_subr_export_HMAC(struct crypto_hmac_key *, uint8_t *,
  57. size_t);
  58. /**
  59. * crypto_keys_subr_generate_RSA(priv, pub):
  60. * Generate an RSA key and store the private and public parts.
  61. */
  62. int crypto_keys_subr_generate_RSA(void **, void **);
  63. /**
  64. * crypto_keys_subr_generate_HMAC(key):
  65. * Generate an HMAC key.
  66. */
  67. int crypto_keys_subr_generate_HMAC(struct crypto_hmac_key **);
  68. /**
  69. * crypto_keys_subr_free_HMAC(key):
  70. * Free an HMAC key.
  71. */
  72. void crypto_keys_subr_free_HMAC(struct crypto_hmac_key **);
  73. /**
  74. * crypto_file_init_keys(void):
  75. * Initialize the keys cached by crypto_file.
  76. */
  77. int crypto_file_init_keys(void);
  78. /**
  79. * crypto_keys_init_keycache(void):
  80. * Initialize the key cache.
  81. */
  82. int crypto_keys_init_keycache(void);
  83. /**
  84. * crypto_MGF1(seed, seedlen, buf, buflen):
  85. * The MGF1 mask generation function, as specified in RFC 3447 section B.2.1,
  86. * using SHA256 as the hash function.
  87. */
  88. void crypto_MGF1(uint8_t *, size_t, uint8_t *, size_t);
  89. #endif /* !CRYPTO_INTERNAL_H_ */