aboutsummaryrefslogtreecommitdiff
path: root/src/identity/identity_api.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-01-07 11:24:52 +0100
committerMartin Schanzenbach <schanzen@gnunet.org>2022-01-07 11:24:52 +0100
commitf92e35100123a64caee591ef6402c6edb4e90897 (patch)
tree39aa0eed3f76723427fda1e09726d15e9fc2dfb5 /src/identity/identity_api.c
parent0ddc76385bb8c29389bcfad9f5737c518861a42c (diff)
downloadgnunet-f92e35100123a64caee591ef6402c6edb4e90897.tar.gz
gnunet-f92e35100123a64caee591ef6402c6edb4e90897.zip
-some input sanitization for identity and abd
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r--src/identity/identity_api.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 01f36b840..4a7a69211 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -954,7 +954,22 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
954} 954}
955 955
956 956
957ssize_t 957static enum GNUNET_GenericReturnValue
958check_key_type (uint32_t type)
959{
960 switch (type)
961 {
962 case GNUNET_IDENTITY_TYPE_ECDSA:
963 case GNUNET_IDENTITY_TYPE_EDDSA:
964 return GNUNET_OK;
965 default:
966 return GNUNET_SYSERR;
967 }
968 return GNUNET_SYSERR;
969}
970
971
972static ssize_t
958private_key_get_length (const struct GNUNET_IDENTITY_PrivateKey *key) 973private_key_get_length (const struct GNUNET_IDENTITY_PrivateKey *key)
959{ 974{
960 switch (ntohl (key->type)) 975 switch (ntohl (key->type))
@@ -1085,7 +1100,7 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct
1085} 1100}
1086 1101
1087 1102
1088int 1103enum GNUNET_GenericReturnValue
1089GNUNET_IDENTITY_sign_ (const struct 1104GNUNET_IDENTITY_sign_ (const struct
1090 GNUNET_IDENTITY_PrivateKey *priv, 1105 GNUNET_IDENTITY_PrivateKey *priv,
1091 const struct 1106 const struct
@@ -1111,7 +1126,7 @@ GNUNET_IDENTITY_sign_ (const struct
1111} 1126}
1112 1127
1113 1128
1114int 1129enum GNUNET_GenericReturnValue
1115GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, 1130GNUNET_IDENTITY_signature_verify_ (uint32_t purpose,
1116 const struct 1131 const struct
1117 GNUNET_CRYPTO_EccSignaturePurpose *validate, 1132 GNUNET_CRYPTO_EccSignaturePurpose *validate,
@@ -1233,7 +1248,6 @@ GNUNET_IDENTITY_private_key_to_string (const struct
1233 size); 1248 size);
1234} 1249}
1235 1250
1236
1237enum GNUNET_GenericReturnValue 1251enum GNUNET_GenericReturnValue
1238GNUNET_IDENTITY_public_key_from_string (const char *str, 1252GNUNET_IDENTITY_public_key_from_string (const char *str,
1239 struct GNUNET_IDENTITY_PublicKey *key) 1253 struct GNUNET_IDENTITY_PublicKey *key)
@@ -1245,7 +1259,7 @@ GNUNET_IDENTITY_public_key_from_string (const char *str,
1245 sizeof (*key)); 1259 sizeof (*key));
1246 if (GNUNET_OK != ret) 1260 if (GNUNET_OK != ret)
1247 return GNUNET_SYSERR; 1261 return GNUNET_SYSERR;
1248 return GNUNET_OK; 1262 return check_key_type (ntohl (key->type));
1249 1263
1250} 1264}
1251 1265
@@ -1261,7 +1275,7 @@ GNUNET_IDENTITY_private_key_from_string (const char *str,
1261 sizeof (*key)); 1275 sizeof (*key));
1262 if (GNUNET_OK != ret) 1276 if (GNUNET_OK != ret)
1263 return GNUNET_SYSERR; 1277 return GNUNET_SYSERR;
1264 return GNUNET_OK; 1278 return check_key_type (ntohl (key->type));
1265} 1279}
1266 1280
1267 1281