diff options
Diffstat (limited to 'src/mint/taler-mint-httpd_refresh.c')
-rw-r--r-- | src/mint/taler-mint-httpd_refresh.c | 113 |
1 files changed, 65 insertions, 48 deletions
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 83225fc15..1f19aedb2 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c | |||
@@ -607,20 +607,20 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, | |||
607 | struct GNUNET_HashCode melt_hash; | 607 | struct GNUNET_HashCode melt_hash; |
608 | 608 | ||
609 | res = TALER_MINT_parse_post_json (connection, | 609 | res = TALER_MINT_parse_post_json (connection, |
610 | connection_cls, | 610 | connection_cls, |
611 | upload_data, | 611 | upload_data, |
612 | upload_data_size, &root); | 612 | upload_data_size, |
613 | &root); | ||
613 | if (GNUNET_SYSERR == res) | 614 | if (GNUNET_SYSERR == res) |
614 | { | ||
615 | // FIXME: return 'internal error'? | ||
616 | GNUNET_break (0); | ||
617 | return MHD_NO; | 615 | return MHD_NO; |
618 | } | 616 | if ( (GNUNET_NO == res) || (NULL == root) ) |
619 | if (GNUNET_NO == res) | ||
620 | return MHD_YES; | 617 | return MHD_YES; |
621 | 618 | ||
622 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) | 619 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) |
623 | return GNUNET_SYSERR; | 620 | { |
621 | /* FIXME: return error code to MHD! */ | ||
622 | return MHD_NO; | ||
623 | } | ||
624 | 624 | ||
625 | /* session_pub field must always be present */ | 625 | /* session_pub field must always be present */ |
626 | res = request_json_require_nav (connection, root, | 626 | res = request_json_require_nav (connection, root, |
@@ -824,19 +824,15 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh, | |||
824 | json_t *root; | 824 | json_t *root; |
825 | 825 | ||
826 | res = TALER_MINT_parse_post_json (connection, | 826 | res = TALER_MINT_parse_post_json (connection, |
827 | connection_cls, | 827 | connection_cls, |
828 | upload_data, | 828 | upload_data, |
829 | upload_data_size, &root); | 829 | upload_data_size, |
830 | &root); | ||
830 | if (GNUNET_SYSERR == res) | 831 | if (GNUNET_SYSERR == res) |
831 | { | ||
832 | // FIXME: return 'internal error'? | ||
833 | GNUNET_break (0); | ||
834 | return MHD_NO; | 832 | return MHD_NO; |
835 | } | 833 | if ( (GNUNET_NO == res) || (NULL == root) ) |
836 | if (GNUNET_NO == res) | ||
837 | return MHD_YES; | 834 | return MHD_YES; |
838 | 835 | ||
839 | |||
840 | res = request_json_require_nav (connection, root, | 836 | res = request_json_require_nav (connection, root, |
841 | JNAV_FIELD, "session_pub", | 837 | JNAV_FIELD, "session_pub", |
842 | JNAV_RET_DATA, | 838 | JNAV_RET_DATA, |
@@ -1160,16 +1156,13 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1160 | json_t *root; | 1156 | json_t *root; |
1161 | 1157 | ||
1162 | res = TALER_MINT_parse_post_json (connection, | 1158 | res = TALER_MINT_parse_post_json (connection, |
1163 | connection_cls, | 1159 | connection_cls, |
1164 | upload_data, upload_data_size, | 1160 | upload_data, |
1165 | &root); | 1161 | upload_data_size, |
1162 | &root); | ||
1166 | if (GNUNET_SYSERR == res) | 1163 | if (GNUNET_SYSERR == res) |
1167 | { | ||
1168 | // FIXME: return 'internal error'? | ||
1169 | GNUNET_break (0); | ||
1170 | return MHD_NO; | 1164 | return MHD_NO; |
1171 | } | 1165 | if ( (GNUNET_NO == res) || (NULL == root) ) |
1172 | if (GNUNET_NO == res) | ||
1173 | return MHD_YES; | 1166 | return MHD_YES; |
1174 | 1167 | ||
1175 | res = request_json_require_nav (connection, root, | 1168 | res = request_json_require_nav (connection, root, |
@@ -1186,6 +1179,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1186 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) | 1179 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) |
1187 | { | 1180 | { |
1188 | GNUNET_break (0); | 1181 | GNUNET_break (0); |
1182 | // FIXME: return 'internal error'? | ||
1189 | return MHD_NO; | 1183 | return MHD_NO; |
1190 | } | 1184 | } |
1191 | 1185 | ||
@@ -1199,6 +1193,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1199 | if (GNUNET_SYSERR == res) | 1193 | if (GNUNET_SYSERR == res) |
1200 | { | 1194 | { |
1201 | GNUNET_break (0); | 1195 | GNUNET_break (0); |
1196 | // FIXME: return 'internal error'? | ||
1202 | return MHD_NO; | 1197 | return MHD_NO; |
1203 | } | 1198 | } |
1204 | 1199 | ||
@@ -1242,14 +1237,16 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1242 | if (GNUNET_OK != res) | 1237 | if (GNUNET_OK != res) |
1243 | { | 1238 | { |
1244 | GNUNET_break (0); | 1239 | GNUNET_break (0); |
1245 | return GNUNET_SYSERR; | 1240 | // FIXME: return 'internal error'? |
1241 | return MHD_NO; | ||
1246 | } | 1242 | } |
1247 | 1243 | ||
1248 | res = TALER_MINT_DB_get_refresh_melt (db_conn, &refresh_session_pub, j, &coin_pub); | 1244 | res = TALER_MINT_DB_get_refresh_melt (db_conn, &refresh_session_pub, j, &coin_pub); |
1249 | if (GNUNET_OK != res) | 1245 | if (GNUNET_OK != res) |
1250 | { | 1246 | { |
1251 | GNUNET_break (0); | 1247 | GNUNET_break (0); |
1252 | return GNUNET_SYSERR; | 1248 | // FIXME: return 'internal error'? |
1249 | return MHD_NO; | ||
1253 | } | 1250 | } |
1254 | 1251 | ||
1255 | /* We're converting key types here, which is not very nice | 1252 | /* We're converting key types here, which is not very nice |
@@ -1259,14 +1256,16 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1259 | &transfer_secret)) | 1256 | &transfer_secret)) |
1260 | { | 1257 | { |
1261 | GNUNET_break (0); | 1258 | GNUNET_break (0); |
1262 | return GNUNET_SYSERR; | 1259 | // FIXME: return 'internal error'? |
1260 | return MHD_NO; | ||
1263 | } | 1261 | } |
1264 | 1262 | ||
1265 | if (0 >= TALER_refresh_decrypt (commit_link.shared_secret_enc, TALER_REFRESH_SHARED_SECRET_LENGTH, | 1263 | if (0 >= TALER_refresh_decrypt (commit_link.shared_secret_enc, TALER_REFRESH_SHARED_SECRET_LENGTH, |
1266 | &transfer_secret, &shared_secret)) | 1264 | &transfer_secret, &shared_secret)) |
1267 | { | 1265 | { |
1268 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decryption failed\n"); | 1266 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decryption failed\n"); |
1269 | return GNUNET_SYSERR; | 1267 | // FIXME: return 'internal error'? |
1268 | return MHD_NO; | ||
1270 | } | 1269 | } |
1271 | 1270 | ||
1272 | if (GNUNET_NO == secret_initialized) | 1271 | if (GNUNET_NO == secret_initialized) |
@@ -1277,7 +1276,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1277 | else if (0 != memcmp (&shared_secret, &last_shared_secret, sizeof (struct GNUNET_HashCode))) | 1276 | else if (0 != memcmp (&shared_secret, &last_shared_secret, sizeof (struct GNUNET_HashCode))) |
1278 | { | 1277 | { |
1279 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "shared secrets do not match\n"); | 1278 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "shared secrets do not match\n"); |
1280 | return GNUNET_SYSERR; | 1279 | // FIXME: return error code! |
1280 | return MHD_NO; | ||
1281 | } | 1281 | } |
1282 | 1282 | ||
1283 | { | 1283 | { |
@@ -1286,7 +1286,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1286 | if (0 != memcmp (&transfer_pub_check, &commit_link.transfer_pub, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 1286 | if (0 != memcmp (&transfer_pub_check, &commit_link.transfer_pub, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) |
1287 | { | 1287 | { |
1288 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "transfer keys do not match\n"); | 1288 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "transfer keys do not match\n"); |
1289 | return GNUNET_SYSERR; | 1289 | // FIXME: return error code! |
1290 | return MHD_NO; | ||
1290 | } | 1291 | } |
1291 | } | 1292 | } |
1292 | } | 1293 | } |
@@ -1310,7 +1311,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1310 | if (GNUNET_OK != res) | 1311 | if (GNUNET_OK != res) |
1311 | { | 1312 | { |
1312 | GNUNET_break (0); | 1313 | GNUNET_break (0); |
1313 | return GNUNET_SYSERR; | 1314 | // FIXME: return error code! |
1315 | return MHD_NO; | ||
1314 | } | 1316 | } |
1315 | 1317 | ||
1316 | 1318 | ||
@@ -1318,20 +1320,23 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1318 | &last_shared_secret, &link_data)) | 1320 | &last_shared_secret, &link_data)) |
1319 | { | 1321 | { |
1320 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decryption failed\n"); | 1322 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decryption failed\n"); |
1321 | return GNUNET_SYSERR; | 1323 | // FIXME: return error code! |
1324 | return MHD_NO; | ||
1322 | } | 1325 | } |
1323 | 1326 | ||
1324 | GNUNET_CRYPTO_ecdsa_key_get_public (&link_data.coin_priv, &coin_pub); | 1327 | GNUNET_CRYPTO_ecdsa_key_get_public (&link_data.coin_priv, &coin_pub); |
1325 | if (NULL == (bkey = TALER_RSA_blinding_key_decode (&link_data.bkey_enc))) | 1328 | if (NULL == (bkey = TALER_RSA_blinding_key_decode (&link_data.bkey_enc))) |
1326 | { | 1329 | { |
1327 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid blinding key\n"); | 1330 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid blinding key\n"); |
1328 | return GNUNET_SYSERR; | 1331 | // FIXME: return error code! |
1332 | return MHD_NO; | ||
1329 | } | 1333 | } |
1330 | res = TALER_MINT_DB_get_refresh_order (db_conn, j, &refresh_session_pub, &denom_pub); | 1334 | res = TALER_MINT_DB_get_refresh_order (db_conn, j, &refresh_session_pub, &denom_pub); |
1331 | if (GNUNET_OK != res) | 1335 | if (GNUNET_OK != res) |
1332 | { | 1336 | { |
1333 | GNUNET_break (0); | 1337 | GNUNET_break (0); |
1334 | return GNUNET_SYSERR; | 1338 | // FIXME: return error code! |
1339 | return MHD_NO; | ||
1335 | } | 1340 | } |
1336 | if (NULL == (coin_ev_check = | 1341 | if (NULL == (coin_ev_check = |
1337 | TALER_RSA_message_blind (&coin_pub, | 1342 | TALER_RSA_message_blind (&coin_pub, |
@@ -1340,7 +1345,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1340 | &denom_pub))) | 1345 | &denom_pub))) |
1341 | { | 1346 | { |
1342 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "blind failed\n"); | 1347 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "blind failed\n"); |
1343 | return GNUNET_SYSERR; | 1348 | // FIXME: return error code! |
1349 | return MHD_NO; | ||
1344 | } | 1350 | } |
1345 | 1351 | ||
1346 | if (0 != memcmp (&coin_ev_check, | 1352 | if (0 != memcmp (&coin_ev_check, |
@@ -1349,7 +1355,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1349 | { | 1355 | { |
1350 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "blind envelope does not match for kappa=%d, old=%d\n", | 1356 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "blind envelope does not match for kappa=%d, old=%d\n", |
1351 | (int) i, (int) j); | 1357 | (int) i, (int) j); |
1352 | return GNUNET_SYSERR; | 1358 | // FIXME: return error code! |
1359 | return MHD_NO; | ||
1353 | } | 1360 | } |
1354 | } | 1361 | } |
1355 | } | 1362 | } |
@@ -1358,6 +1365,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1358 | if (GNUNET_OK != TALER_MINT_DB_transaction (db_conn)) | 1365 | if (GNUNET_OK != TALER_MINT_DB_transaction (db_conn)) |
1359 | { | 1366 | { |
1360 | GNUNET_break (0); | 1367 | GNUNET_break (0); |
1368 | // FIXME: return error code! | ||
1361 | return MHD_NO; | 1369 | return MHD_NO; |
1362 | } | 1370 | } |
1363 | 1371 | ||
@@ -1376,13 +1384,15 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1376 | if (GNUNET_OK != res) | 1384 | if (GNUNET_OK != res) |
1377 | { | 1385 | { |
1378 | GNUNET_break (0); | 1386 | GNUNET_break (0); |
1379 | return GNUNET_SYSERR; | 1387 | // FIXME: return error code! |
1388 | return MHD_NO; | ||
1380 | } | 1389 | } |
1381 | res = TALER_MINT_DB_get_refresh_order (db_conn, j, &refresh_session_pub, &denom_pub); | 1390 | res = TALER_MINT_DB_get_refresh_order (db_conn, j, &refresh_session_pub, &denom_pub); |
1382 | if (GNUNET_OK != res) | 1391 | if (GNUNET_OK != res) |
1383 | { | 1392 | { |
1384 | GNUNET_break (0); | 1393 | GNUNET_break (0); |
1385 | return GNUNET_SYSERR; | 1394 | // FIXME: return error code! |
1395 | return MHD_NO; | ||
1386 | } | 1396 | } |
1387 | 1397 | ||
1388 | 1398 | ||
@@ -1392,7 +1402,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1392 | if (NULL == dki) | 1402 | if (NULL == dki) |
1393 | { | 1403 | { |
1394 | GNUNET_break (0); | 1404 | GNUNET_break (0); |
1395 | return GNUNET_SYSERR; | 1405 | // FIXME: return error code! |
1406 | return MHD_NO; | ||
1396 | } | 1407 | } |
1397 | if (GNUNET_OK != | 1408 | if (GNUNET_OK != |
1398 | TALER_RSA_sign (dki->denom_priv, | 1409 | TALER_RSA_sign (dki->denom_priv, |
@@ -1401,7 +1412,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1401 | &ev_sig)) | 1412 | &ev_sig)) |
1402 | { | 1413 | { |
1403 | GNUNET_break (0); | 1414 | GNUNET_break (0); |
1404 | return GNUNET_SYSERR; | 1415 | // FIXME: return error code! |
1416 | return MHD_NO; | ||
1405 | } | 1417 | } |
1406 | 1418 | ||
1407 | res = TALER_MINT_DB_insert_refresh_collectable (db_conn, | 1419 | res = TALER_MINT_DB_insert_refresh_collectable (db_conn, |
@@ -1411,7 +1423,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1411 | if (GNUNET_OK != res) | 1423 | if (GNUNET_OK != res) |
1412 | { | 1424 | { |
1413 | GNUNET_break (0); | 1425 | GNUNET_break (0); |
1414 | return GNUNET_SYSERR; | 1426 | // FIXME: return error code! |
1427 | return MHD_NO; | ||
1415 | } | 1428 | } |
1416 | } | 1429 | } |
1417 | /* mark that reveal was successful */ | 1430 | /* mark that reveal was successful */ |
@@ -1420,7 +1433,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
1420 | if (GNUNET_OK != res) | 1433 | if (GNUNET_OK != res) |
1421 | { | 1434 | { |
1422 | GNUNET_break (0); | 1435 | GNUNET_break (0); |
1423 | return GNUNET_SYSERR; | 1436 | // FIXME: return error code! |
1437 | return MHD_NO; | ||
1424 | } | 1438 | } |
1425 | 1439 | ||
1426 | if (GNUNET_OK != TALER_MINT_DB_commit (db_conn)) | 1440 | if (GNUNET_OK != TALER_MINT_DB_commit (db_conn)) |
@@ -1459,9 +1473,9 @@ TALER_MINT_handler_refresh_link (struct RequestHandler *rh, | |||
1459 | struct SharedSecretEnc shared_secret_enc; | 1473 | struct SharedSecretEnc shared_secret_enc; |
1460 | 1474 | ||
1461 | res = TALER_MINT_mhd_request_arg_data (connection, | 1475 | res = TALER_MINT_mhd_request_arg_data (connection, |
1462 | "coin_pub", | 1476 | "coin_pub", |
1463 | &coin_pub, | 1477 | &coin_pub, |
1464 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 1478 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); |
1465 | if (GNUNET_SYSERR == res) | 1479 | if (GNUNET_SYSERR == res) |
1466 | { | 1480 | { |
1467 | // FIXME: return 'internal error' | 1481 | // FIXME: return 'internal error' |
@@ -1474,7 +1488,8 @@ TALER_MINT_handler_refresh_link (struct RequestHandler *rh, | |||
1474 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) | 1488 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) |
1475 | { | 1489 | { |
1476 | GNUNET_break (0); | 1490 | GNUNET_break (0); |
1477 | return GNUNET_SYSERR; | 1491 | // FIXME: return error code! |
1492 | return MHD_NO; | ||
1478 | } | 1493 | } |
1479 | 1494 | ||
1480 | list = json_array (); | 1495 | list = json_array (); |
@@ -1488,6 +1503,7 @@ TALER_MINT_handler_refresh_link (struct RequestHandler *rh, | |||
1488 | if (GNUNET_SYSERR == res) | 1503 | if (GNUNET_SYSERR == res) |
1489 | { | 1504 | { |
1490 | GNUNET_break (0); | 1505 | GNUNET_break (0); |
1506 | // FIXME: return error code! | ||
1491 | return MHD_NO; | 1507 | return MHD_NO; |
1492 | } | 1508 | } |
1493 | if (GNUNET_NO == res) | 1509 | if (GNUNET_NO == res) |
@@ -1504,6 +1520,7 @@ TALER_MINT_handler_refresh_link (struct RequestHandler *rh, | |||
1504 | if (GNUNET_SYSERR == res) | 1520 | if (GNUNET_SYSERR == res) |
1505 | { | 1521 | { |
1506 | GNUNET_break (0); | 1522 | GNUNET_break (0); |
1523 | // FIXME: return error code! | ||
1507 | return MHD_NO; | 1524 | return MHD_NO; |
1508 | } | 1525 | } |
1509 | if (GNUNET_NO == res) | 1526 | if (GNUNET_NO == res) |