signkey.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Dropbear - a SSH2 server
  3. *
  4. * Copyright (c) 2002,2003 Matt Johnston
  5. * All rights reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. * SOFTWARE. */
  24. #ifndef DROPBEAR_SIGNKEY_H_
  25. #define DROPBEAR_SIGNKEY_H_
  26. #include "buffer.h"
  27. #include "dss.h"
  28. #include "rsa.h"
  29. enum signkey_type {
  30. #ifdef DROPBEAR_RSA
  31. DROPBEAR_SIGNKEY_RSA,
  32. #endif
  33. #ifdef DROPBEAR_DSS
  34. DROPBEAR_SIGNKEY_DSS,
  35. #endif
  36. #ifdef DROPBEAR_ECDSA
  37. DROPBEAR_SIGNKEY_ECDSA_NISTP256,
  38. DROPBEAR_SIGNKEY_ECDSA_NISTP384,
  39. DROPBEAR_SIGNKEY_ECDSA_NISTP521,
  40. #endif /* DROPBEAR_ECDSA */
  41. DROPBEAR_SIGNKEY_NUM_NAMED,
  42. DROPBEAR_SIGNKEY_ECDSA_KEYGEN = 70, /* just "ecdsa" for keygen */
  43. DROPBEAR_SIGNKEY_ANY = 80,
  44. DROPBEAR_SIGNKEY_NONE = 90,
  45. };
  46. /* Sources for signing keys */
  47. typedef enum {
  48. SIGNKEY_SOURCE_RAW_FILE,
  49. SIGNKEY_SOURCE_AGENT,
  50. SIGNKEY_SOURCE_INVALID,
  51. } signkey_source;
  52. struct SIGN_key {
  53. enum signkey_type type;
  54. signkey_source source;
  55. char *filename;
  56. #ifdef DROPBEAR_DSS
  57. dropbear_dss_key * dsskey;
  58. #endif
  59. #ifdef DROPBEAR_RSA
  60. dropbear_rsa_key * rsakey;
  61. #endif
  62. #ifdef DROPBEAR_ECDSA
  63. #ifdef DROPBEAR_ECC_256
  64. ecc_key * ecckey256;
  65. #endif
  66. #ifdef DROPBEAR_ECC_384
  67. ecc_key * ecckey384;
  68. #endif
  69. #ifdef DROPBEAR_ECC_521
  70. ecc_key * ecckey521;
  71. #endif
  72. #endif
  73. };
  74. typedef struct SIGN_key sign_key;
  75. sign_key * new_sign_key(void);
  76. const char* signkey_name_from_type(enum signkey_type type, unsigned int *namelen);
  77. enum signkey_type signkey_type_from_name(const char* name, unsigned int namelen);
  78. int buf_get_pub_key(buffer *buf, sign_key *key, enum signkey_type *type);
  79. int buf_get_priv_key(buffer* buf, sign_key *key, enum signkey_type *type);
  80. void buf_put_pub_key(buffer* buf, sign_key *key, enum signkey_type type);
  81. void buf_put_priv_key(buffer* buf, sign_key *key, enum signkey_type type);
  82. void sign_key_free(sign_key *key);
  83. void buf_put_sign(buffer* buf, sign_key *key, enum signkey_type type, buffer *data_buf);
  84. #ifdef DROPBEAR_SIGNKEY_VERIFY
  85. int buf_verify(buffer * buf, sign_key *key, buffer *data_buf);
  86. char * sign_key_fingerprint(unsigned char* keyblob, unsigned int keybloblen);
  87. #endif
  88. int cmp_base64_key(const unsigned char* keyblob, unsigned int keybloblen,
  89. const unsigned char* algoname, unsigned int algolen,
  90. buffer * line, char ** fingerprint);
  91. void** signkey_key_ptr(sign_key *key, enum signkey_type type);
  92. #endif /* DROPBEAR_SIGNKEY_H_ */