diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-02-01 15:48:52 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-02-01 15:48:52 +0100 |
commit | 816bab695d6a7f4e359865e83b687d45ff66a2b1 (patch) | |
tree | 9e36e1d3d61e402a00119b727855fd71f01b795c /src/identity/identity_api.c | |
parent | 8e8f974d798b20e298de6583e8ad0b07ef9b0992 (diff) | |
download | gnunet-816bab695d6a7f4e359865e83b687d45ff66a2b1.tar.gz gnunet-816bab695d6a7f4e359865e83b687d45ff66a2b1.zip |
GNS: Fix revocation wire format
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r-- | src/identity/identity_api.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 4a7a69211..471569cb3 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -1063,6 +1063,25 @@ GNUNET_IDENTITY_signature_get_length (const struct | |||
1063 | 1063 | ||
1064 | 1064 | ||
1065 | ssize_t | 1065 | ssize_t |
1066 | GNUNET_IDENTITY_signature_get_raw_length_by_type (uint32_t type) | ||
1067 | { | ||
1068 | switch (ntohl (type)) | ||
1069 | { | ||
1070 | case GNUNET_IDENTITY_TYPE_ECDSA: | ||
1071 | return sizeof (struct GNUNET_CRYPTO_EcdsaSignature); | ||
1072 | break; | ||
1073 | case GNUNET_IDENTITY_TYPE_EDDSA: | ||
1074 | return sizeof (struct GNUNET_CRYPTO_EddsaSignature); | ||
1075 | break; | ||
1076 | default: | ||
1077 | GNUNET_break (0); | ||
1078 | } | ||
1079 | return -1; | ||
1080 | } | ||
1081 | |||
1082 | |||
1083 | |||
1084 | ssize_t | ||
1066 | GNUNET_IDENTITY_read_signature_from_buffer (struct | 1085 | GNUNET_IDENTITY_read_signature_from_buffer (struct |
1067 | GNUNET_IDENTITY_Signature *sig, | 1086 | GNUNET_IDENTITY_Signature *sig, |
1068 | const void*buffer, | 1087 | const void*buffer, |
@@ -1099,6 +1118,31 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct | |||
1099 | return length; | 1118 | return length; |
1100 | } | 1119 | } |
1101 | 1120 | ||
1121 | enum GNUNET_GenericReturnValue | ||
1122 | GNUNET_IDENTITY_sign_raw_ (const struct | ||
1123 | GNUNET_IDENTITY_PrivateKey *priv, | ||
1124 | const struct | ||
1125 | GNUNET_CRYPTO_EccSignaturePurpose *purpose, | ||
1126 | unsigned char *sig) | ||
1127 | { | ||
1128 | switch (ntohl (priv->type)) | ||
1129 | { | ||
1130 | case GNUNET_IDENTITY_TYPE_ECDSA: | ||
1131 | return GNUNET_CRYPTO_ecdsa_sign_ (&(priv->ecdsa_key), purpose, | ||
1132 | (struct GNUNET_CRYPTO_EcdsaSignature*)sig); | ||
1133 | break; | ||
1134 | case GNUNET_IDENTITY_TYPE_EDDSA: | ||
1135 | return GNUNET_CRYPTO_eddsa_sign_ (&(priv->eddsa_key), purpose, | ||
1136 | (struct GNUNET_CRYPTO_EddsaSignature*)sig); | ||
1137 | break; | ||
1138 | default: | ||
1139 | GNUNET_break (0); | ||
1140 | } | ||
1141 | |||
1142 | return GNUNET_SYSERR; | ||
1143 | } | ||
1144 | |||
1145 | |||
1102 | 1146 | ||
1103 | enum GNUNET_GenericReturnValue | 1147 | enum GNUNET_GenericReturnValue |
1104 | GNUNET_IDENTITY_sign_ (const struct | 1148 | GNUNET_IDENTITY_sign_ (const struct |
@@ -1155,6 +1199,37 @@ GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, | |||
1155 | } | 1199 | } |
1156 | 1200 | ||
1157 | 1201 | ||
1202 | enum GNUNET_GenericReturnValue | ||
1203 | GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose, | ||
1204 | const struct | ||
1205 | GNUNET_CRYPTO_EccSignaturePurpose * | ||
1206 | validate, | ||
1207 | const unsigned char *sig, | ||
1208 | const struct | ||
1209 | GNUNET_IDENTITY_PublicKey *pub) | ||
1210 | { | ||
1211 | switch (ntohl (pub->type)) | ||
1212 | { | ||
1213 | case GNUNET_IDENTITY_TYPE_ECDSA: | ||
1214 | return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate, | ||
1215 | (struct GNUNET_CRYPTO_EcdsaSignature*)sig, | ||
1216 | &(pub->ecdsa_key)); | ||
1217 | break; | ||
1218 | case GNUNET_IDENTITY_TYPE_EDDSA: | ||
1219 | return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate, | ||
1220 | (struct GNUNET_CRYPTO_EddsaSignature*)sig, | ||
1221 | &(pub->eddsa_key)); | ||
1222 | break; | ||
1223 | default: | ||
1224 | GNUNET_break (0); | ||
1225 | } | ||
1226 | |||
1227 | return GNUNET_SYSERR; | ||
1228 | } | ||
1229 | |||
1230 | |||
1231 | |||
1232 | |||
1158 | ssize_t | 1233 | ssize_t |
1159 | GNUNET_IDENTITY_encrypt (const void *block, | 1234 | GNUNET_IDENTITY_encrypt (const void *block, |
1160 | size_t size, | 1235 | size_t size, |