diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-01-07 11:24:52 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-01-07 11:24:52 +0100 |
commit | f92e35100123a64caee591ef6402c6edb4e90897 (patch) | |
tree | 39aa0eed3f76723427fda1e09726d15e9fc2dfb5 /src | |
parent | 0ddc76385bb8c29389bcfad9f5737c518861a42c (diff) | |
download | gnunet-f92e35100123a64caee591ef6402c6edb4e90897.tar.gz gnunet-f92e35100123a64caee591ef6402c6edb4e90897.zip |
-some input sanitization for identity and abd
Diffstat (limited to 'src')
-rw-r--r-- | src/abd/gnunet-abd.c | 12 | ||||
-rw-r--r-- | src/identity/identity_api.c | 26 | ||||
-rw-r--r-- | src/include/gnunet_identity_service.h | 4 |
3 files changed, 32 insertions, 10 deletions
diff --git a/src/abd/gnunet-abd.c b/src/abd/gnunet-abd.c index cf3733abd..9f5fef958 100644 --- a/src/abd/gnunet-abd.c +++ b/src/abd/gnunet-abd.c | |||
@@ -560,6 +560,14 @@ store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
560 | return; | 560 | return; |
561 | } | 561 | } |
562 | 562 | ||
563 | if (NULL == ego) | ||
564 | { | ||
565 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
566 | _("Ego does not exist!\n")); | ||
567 | GNUNET_SCHEDULER_shutdown (); | ||
568 | return; | ||
569 | } | ||
570 | |||
563 | // Key handling | 571 | // Key handling |
564 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); | 572 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); |
565 | 573 | ||
@@ -611,12 +619,12 @@ store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
611 | { | 619 | { |
612 | if (typestring == NULL) | 620 | if (typestring == NULL) |
613 | { | 621 | { |
614 | fputs ("No value for unknown record type\n", stderr); | 622 | fputs ("Value for unknown record type not well-formed.\n", stderr); |
615 | } | 623 | } |
616 | else if (subject == NULL) | 624 | else if (subject == NULL) |
617 | { | 625 | { |
618 | fprintf (stderr, | 626 | fprintf (stderr, |
619 | "No value for record type`%s'\n", | 627 | "Value for record type `%s' not well-formed.\n", |
620 | typestring); | 628 | typestring); |
621 | } | 629 | } |
622 | else | 630 | else |
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 | ||
957 | ssize_t | 957 | static enum GNUNET_GenericReturnValue |
958 | check_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 | |||
972 | static ssize_t | ||
958 | private_key_get_length (const struct GNUNET_IDENTITY_PrivateKey *key) | 973 | private_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 | ||
1088 | int | 1103 | enum GNUNET_GenericReturnValue |
1089 | GNUNET_IDENTITY_sign_ (const struct | 1104 | GNUNET_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 | ||
1114 | int | 1129 | enum GNUNET_GenericReturnValue |
1115 | GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, | 1130 | GNUNET_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 | |||
1237 | enum GNUNET_GenericReturnValue | 1251 | enum GNUNET_GenericReturnValue |
1238 | GNUNET_IDENTITY_public_key_from_string (const char *str, | 1252 | GNUNET_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 | ||
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index e40a741bf..b2a45577f 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h | |||
@@ -509,7 +509,7 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct | |||
509 | * @param[out] sig where to write the signature | 509 | * @param[out] sig where to write the signature |
510 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 510 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
511 | */ | 511 | */ |
512 | int | 512 | enum GNUNET_GenericReturnValue |
513 | GNUNET_IDENTITY_sign_ (const struct | 513 | GNUNET_IDENTITY_sign_ (const struct |
514 | GNUNET_IDENTITY_PrivateKey *priv, | 514 | GNUNET_IDENTITY_PrivateKey *priv, |
515 | const struct | 515 | const struct |
@@ -558,7 +558,7 @@ GNUNET_IDENTITY_sign_ (const struct | |||
558 | * @param pub public key of the signer | 558 | * @param pub public key of the signer |
559 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 559 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
560 | */ | 560 | */ |
561 | int | 561 | enum GNUNET_GenericReturnValue |
562 | GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, | 562 | GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, |
563 | const struct | 563 | const struct |
564 | GNUNET_CRYPTO_EccSignaturePurpose *validate, | 564 | GNUNET_CRYPTO_EccSignaturePurpose *validate, |