diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-29 19:21:20 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-29 19:21:20 +0000 |
commit | e2eb1cbf30d6f59d9ad94e104317b245ef9b1d56 (patch) | |
tree | e4e4b8a6f03f5cff579ca093a333ca4a7a353591 /src/include/gnunet_crypto_lib.h | |
parent | 46ba82641c0feb4b04ff489038543e576a0c78ee (diff) | |
download | gnunet-e2eb1cbf30d6f59d9ad94e104317b245ef9b1d56.tar.gz gnunet-e2eb1cbf30d6f59d9ad94e104317b245ef9b1d56.zip |
serialize privat key
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 63d3ee418..3d2c946b0 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -101,6 +101,32 @@ enum GNUNET_CRYPTO_Quality | |||
101 | */ | 101 | */ |
102 | struct GNUNET_CRYPTO_RsaPrivateKey; | 102 | struct GNUNET_CRYPTO_RsaPrivateKey; |
103 | 103 | ||
104 | GNUNET_NETWORK_STRUCT_BEGIN | ||
105 | |||
106 | /** | ||
107 | * GNUnet mandates a certain format for the encoding | ||
108 | * of private RSA key information that is provided | ||
109 | * by the RSA implementations. This format is used | ||
110 | * to serialize a private RSA key (typically when | ||
111 | * writing it to disk). | ||
112 | */ | ||
113 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded | ||
114 | { | ||
115 | /** | ||
116 | * Total size of the structure, in bytes, in big-endian! | ||
117 | */ | ||
118 | uint16_t len GNUNET_PACKED; | ||
119 | uint16_t sizen GNUNET_PACKED; /* in big-endian! */ | ||
120 | uint16_t sizee GNUNET_PACKED; /* in big-endian! */ | ||
121 | uint16_t sized GNUNET_PACKED; /* in big-endian! */ | ||
122 | uint16_t sizep GNUNET_PACKED; /* in big-endian! */ | ||
123 | uint16_t sizeq GNUNET_PACKED; /* in big-endian! */ | ||
124 | uint16_t sizedmp1 GNUNET_PACKED; /* in big-endian! */ | ||
125 | uint16_t sizedmq1 GNUNET_PACKED; /* in big-endian! */ | ||
126 | /* followed by the actual values */ | ||
127 | }; | ||
128 | GNUNET_NETWORK_STRUCT_END | ||
129 | |||
104 | 130 | ||
105 | /** | 131 | /** |
106 | * @brief 0-terminated ASCII encoding of a GNUNET_HashCode. | 132 | * @brief 0-terminated ASCII encoding of a GNUNET_HashCode. |
@@ -736,6 +762,15 @@ struct GNUNET_CRYPTO_RsaPrivateKey * | |||
736 | GNUNET_CRYPTO_rsa_key_create (void); | 762 | GNUNET_CRYPTO_rsa_key_create (void); |
737 | 763 | ||
738 | /** | 764 | /** |
765 | * Encode the private key in a format suitable for | ||
766 | * storing it into a file. | ||
767 | * @returns encoding of the private key. | ||
768 | * The first 4 bytes give the size of the array, as usual. | ||
769 | */ | ||
770 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * | ||
771 | GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey); | ||
772 | |||
773 | /** | ||
739 | * Decode the private key from the data-format back | 774 | * Decode the private key from the data-format back |
740 | * to the "normal", internal format. | 775 | * to the "normal", internal format. |
741 | * | 776 | * |