diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-10 14:38:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-10 14:38:55 +0000 |
commit | 9351b1e9bdf2b067b6db06562c26ba658cff42b8 (patch) | |
tree | 68dc4ab447e7e8b6a20a706858cd36238c1c7c5f /src/namestore/plugin_namestore_sqlite.c | |
parent | 8beabcd96c0cf1e1873c0b5ff96e537f1beb0b34 (diff) | |
download | gnunet-9351b1e9bdf2b067b6db06562c26ba658cff42b8.tar.gz gnunet-9351b1e9bdf2b067b6db06562c26ba658cff42b8.zip |
separating ECC crypto into functions/structs for ECDHE, ECDSA and EDDSA
Diffstat (limited to 'src/namestore/plugin_namestore_sqlite.c')
-rw-r--r-- | src/namestore/plugin_namestore_sqlite.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index 19fa86bf3..729b916ca 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c | |||
@@ -467,15 +467,15 @@ namestore_sqlite_cache_block (void *cls, | |||
467 | 467 | ||
468 | namestore_sqlite_expire_blocks (plugin); | 468 | namestore_sqlite_expire_blocks (plugin); |
469 | GNUNET_CRYPTO_hash (&block->derived_key, | 469 | GNUNET_CRYPTO_hash (&block->derived_key, |
470 | sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), | 470 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), |
471 | &query); | 471 | &query); |
472 | expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time); | 472 | expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time); |
473 | dval = (int64_t) expiration.abs_value_us; | 473 | dval = (int64_t) expiration.abs_value_us; |
474 | if (dval < 0) | 474 | if (dval < 0) |
475 | dval = INT64_MAX; | 475 | dval = INT64_MAX; |
476 | block_size = ntohl (block->purpose.size) + | 476 | block_size = ntohl (block->purpose.size) + |
477 | sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) + | 477 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + |
478 | sizeof (struct GNUNET_CRYPTO_EccSignature); | 478 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature); |
479 | if (block_size > 64 * 65536) | 479 | if (block_size > 64 * 65536) |
480 | { | 480 | { |
481 | GNUNET_break (0); | 481 | GNUNET_break (0); |
@@ -606,8 +606,8 @@ namestore_sqlite_lookup_block (void *cls, | |||
606 | block_size = sqlite3_column_bytes (plugin->lookup_block, 0); | 606 | block_size = sqlite3_column_bytes (plugin->lookup_block, 0); |
607 | if ( (block_size < sizeof (struct GNUNET_NAMESTORE_Block)) || | 607 | if ( (block_size < sizeof (struct GNUNET_NAMESTORE_Block)) || |
608 | (ntohl (block->purpose.size) + | 608 | (ntohl (block->purpose.size) + |
609 | sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) + | 609 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + |
610 | sizeof (struct GNUNET_CRYPTO_EccSignature) != block_size) ) | 610 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature) != block_size) ) |
611 | { | 611 | { |
612 | GNUNET_break (0); | 612 | GNUNET_break (0); |
613 | ret = GNUNET_SYSERR; | 613 | ret = GNUNET_SYSERR; |
@@ -656,14 +656,14 @@ namestore_sqlite_lookup_block (void *cls, | |||
656 | */ | 656 | */ |
657 | static int | 657 | static int |
658 | namestore_sqlite_store_records (void *cls, | 658 | namestore_sqlite_store_records (void *cls, |
659 | const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, | 659 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
660 | const char *label, | 660 | const char *label, |
661 | unsigned int rd_count, | 661 | unsigned int rd_count, |
662 | const struct GNUNET_NAMESTORE_RecordData *rd) | 662 | const struct GNUNET_NAMESTORE_RecordData *rd) |
663 | { | 663 | { |
664 | struct Plugin *plugin = cls; | 664 | struct Plugin *plugin = cls; |
665 | int n; | 665 | int n; |
666 | struct GNUNET_CRYPTO_EccPublicSignKey pkey; | 666 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; |
667 | uint64_t rvalue; | 667 | uint64_t rvalue; |
668 | size_t data_size; | 668 | size_t data_size; |
669 | unsigned int i; | 669 | unsigned int i; |
@@ -672,7 +672,7 @@ namestore_sqlite_store_records (void *cls, | |||
672 | for (i=0;i<rd_count;i++) | 672 | for (i=0;i<rd_count;i++) |
673 | if (GNUNET_NAMESTORE_TYPE_PKEY == rd[i].record_type) | 673 | if (GNUNET_NAMESTORE_TYPE_PKEY == rd[i].record_type) |
674 | { | 674 | { |
675 | GNUNET_break (sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) == rd[i].data_size); | 675 | GNUNET_break (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) == rd[i].data_size); |
676 | memcpy (&pkey, | 676 | memcpy (&pkey, |
677 | rd[i].data, | 677 | rd[i].data, |
678 | rd[i].data_size); | 678 | rd[i].data_size); |
@@ -697,7 +697,7 @@ namestore_sqlite_store_records (void *cls, | |||
697 | 697 | ||
698 | /* First delete 'old' records */ | 698 | /* First delete 'old' records */ |
699 | if ((SQLITE_OK != sqlite3_bind_blob (plugin->delete_records, 1, | 699 | if ((SQLITE_OK != sqlite3_bind_blob (plugin->delete_records, 1, |
700 | zone_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), SQLITE_STATIC)) || | 700 | zone_key, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), SQLITE_STATIC)) || |
701 | (SQLITE_OK != sqlite3_bind_text (plugin->delete_records, 2, label, -1, SQLITE_STATIC))) | 701 | (SQLITE_OK != sqlite3_bind_text (plugin->delete_records, 2, label, -1, SQLITE_STATIC))) |
702 | { | 702 | { |
703 | LOG_SQLITE (plugin, | 703 | LOG_SQLITE (plugin, |
@@ -718,9 +718,9 @@ namestore_sqlite_store_records (void *cls, | |||
718 | if (0 != rd_count) | 718 | if (0 != rd_count) |
719 | { | 719 | { |
720 | if ((SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 1, | 720 | if ((SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 1, |
721 | zone_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), SQLITE_STATIC)) || | 721 | zone_key, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), SQLITE_STATIC)) || |
722 | (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 2, | 722 | (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 2, |
723 | &pkey, sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), SQLITE_STATIC)) || | 723 | &pkey, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), SQLITE_STATIC)) || |
724 | (SQLITE_OK != sqlite3_bind_int64 (plugin->store_records, 3, rvalue)) || | 724 | (SQLITE_OK != sqlite3_bind_int64 (plugin->store_records, 3, rvalue)) || |
725 | (SQLITE_OK != sqlite3_bind_int (plugin->store_records, 4, rd_count)) || | 725 | (SQLITE_OK != sqlite3_bind_int (plugin->store_records, 4, rd_count)) || |
726 | (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 5, data, data_size, SQLITE_STATIC)) || | 726 | (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 5, data, data_size, SQLITE_STATIC)) || |
@@ -776,7 +776,7 @@ namestore_sqlite_store_records (void *cls, | |||
776 | static int | 776 | static int |
777 | get_record_and_call_iterator (struct Plugin *plugin, | 777 | get_record_and_call_iterator (struct Plugin *plugin, |
778 | sqlite3_stmt *stmt, | 778 | sqlite3_stmt *stmt, |
779 | const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, | 779 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
780 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) | 780 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) |
781 | { | 781 | { |
782 | unsigned int record_count; | 782 | unsigned int record_count; |
@@ -796,7 +796,7 @@ get_record_and_call_iterator (struct Plugin *plugin, | |||
796 | if (NULL == zone_key) | 796 | if (NULL == zone_key) |
797 | { | 797 | { |
798 | /* must be "iterate_all_zones", got one extra return value */ | 798 | /* must be "iterate_all_zones", got one extra return value */ |
799 | if (sizeof (struct GNUNET_CRYPTO_EccPrivateKey) != | 799 | if (sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey) != |
800 | sqlite3_column_bytes (stmt, 3)) | 800 | sqlite3_column_bytes (stmt, 3)) |
801 | { | 801 | { |
802 | GNUNET_break (0); | 802 | GNUNET_break (0); |
@@ -859,7 +859,7 @@ get_record_and_call_iterator (struct Plugin *plugin, | |||
859 | */ | 859 | */ |
860 | static int | 860 | static int |
861 | namestore_sqlite_iterate_records (void *cls, | 861 | namestore_sqlite_iterate_records (void *cls, |
862 | const struct GNUNET_CRYPTO_EccPrivateKey *zone, | 862 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
863 | uint64_t offset, | 863 | uint64_t offset, |
864 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) | 864 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) |
865 | { | 865 | { |
@@ -877,7 +877,7 @@ namestore_sqlite_iterate_records (void *cls, | |||
877 | { | 877 | { |
878 | stmt = plugin->iterate_zone; | 878 | stmt = plugin->iterate_zone; |
879 | err = ( (SQLITE_OK != sqlite3_bind_blob (stmt, 1, | 879 | err = ( (SQLITE_OK != sqlite3_bind_blob (stmt, 1, |
880 | zone, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), | 880 | zone, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), |
881 | SQLITE_STATIC)) || | 881 | SQLITE_STATIC)) || |
882 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, | 882 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, |
883 | offset)) ); | 883 | offset)) ); |
@@ -909,8 +909,8 @@ namestore_sqlite_iterate_records (void *cls, | |||
909 | */ | 909 | */ |
910 | static int | 910 | static int |
911 | namestore_sqlite_zone_to_name (void *cls, | 911 | namestore_sqlite_zone_to_name (void *cls, |
912 | const struct GNUNET_CRYPTO_EccPrivateKey *zone, | 912 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
913 | const struct GNUNET_CRYPTO_EccPublicSignKey *value_zone, | 913 | const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, |
914 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) | 914 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) |
915 | { | 915 | { |
916 | struct Plugin *plugin = cls; | 916 | struct Plugin *plugin = cls; |
@@ -918,10 +918,10 @@ namestore_sqlite_zone_to_name (void *cls, | |||
918 | 918 | ||
919 | stmt = plugin->zone_to_name; | 919 | stmt = plugin->zone_to_name; |
920 | if ( (SQLITE_OK != sqlite3_bind_blob (stmt, 1, | 920 | if ( (SQLITE_OK != sqlite3_bind_blob (stmt, 1, |
921 | zone, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), | 921 | zone, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), |
922 | SQLITE_STATIC)) || | 922 | SQLITE_STATIC)) || |
923 | (SQLITE_OK != sqlite3_bind_blob (stmt, 2, | 923 | (SQLITE_OK != sqlite3_bind_blob (stmt, 2, |
924 | value_zone, sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), | 924 | value_zone, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), |
925 | SQLITE_STATIC)) ) | 925 | SQLITE_STATIC)) ) |
926 | { | 926 | { |
927 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 927 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |