From c29a3d884df0540c1b371fa55b8d92efa11d2820 Mon Sep 17 00:00:00 2001 From: Ibraheem Saleh Date: Tue, 5 Apr 2022 10:41:42 -0700 Subject: [PATCH] AMMOSGH32: Fix arsnw queries from MariaDB interface, remove arsnw_len, fix acs/ecs algo enum in KMC crypto interface --- .../create_sadb.sql | 1 - ...db_jpl_unit_test_security_associations.sql | 20 ++++++------ ...e_sadb_unit_test_security_associations.sql | 32 +++++++++---------- ...hy_interface_kmc_crypto_service.template.c | 14 ++++---- src/src_main/crypto_print.c | 4 +-- src/src_mysql/sadb_routine_mariadb.template.c | 12 +++---- 6 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb.sql b/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb.sql index e0c9d82a..246facd4 100644 --- a/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb.sql +++ b/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb.sql @@ -31,7 +31,6 @@ CREATE TABLE IF NOT EXISTS security_associations ,abm VARBINARY(1024) NOT NULL DEFAULT X'0000FC0000FFFF000000000000000000000000' -- ABM_SIZE=1024 ,arsn_len SMALLINT NOT NULL DEFAULT 0 ,arsn VARBINARY(20) NOT NULL DEFAULT X'0000000000000000000000000000000000000000' -- ARSN_SIZE=20 , TBD why so large... - ,arsnw_len SMALLINT ,arsnw SMALLINT NOT NULL DEFAULT 0 -- ARSNW_SIZE=1 ); diff --git a/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb_jpl_unit_test_security_associations.sql b/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb_jpl_unit_test_security_associations.sql index d4116980..4cf57edc 100644 --- a/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb_jpl_unit_test_security_associations.sql +++ b/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb_jpl_unit_test_security_associations.sql @@ -2,22 +2,22 @@ USE sadb; -- SCID 44 (MMT) Security Associations AES/GCM/NoPadding -- -- SA 1 - OPERATIONAL; ENC + AUTH - ARSNW:5; AES-GCM; IV:00...01; IV-len:12; MAC-len:16; Key-ID: 130, SCID 44, VC-0 -INSERT INTO security_associations (spi,ekid,sa_state,ecs,est,ast,shivf_len,iv_len,stmacf_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len,tfvn,scid,vcid,mapid) -VALUES (1,'kmc/test/key130',3,X'01',1,1,12,12,16,X'000000000000000000000001',19,X'00000000000000000000000000000000000000',1,5,0,0,44,0,0); +INSERT INTO security_associations (spi,ekid,sa_state,ecs,est,ast,shivf_len,iv_len,stmacf_len,iv,abm_len,abm,arsnw,arsn_len,tfvn,scid,vcid,mapid) +VALUES (1,'kmc/test/key130',3,X'01',1,1,12,12,16,X'000000000000000000000001',19,X'00000000000000000000000000000000000000',5,0,0,44,0,0); -- SA 2 - OPERATIONAL; ENC + AUTH - ARSNW:5; AES-GCM; IV:00...01; IV-len:12; MAC-len:16; Key-ID: 130, SCID 44, VC-1 -INSERT INTO security_associations (spi,ekid,sa_state,ecs,est,ast,shivf_len,iv_len,stmacf_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len,tfvn,scid,vcid,mapid) -VALUES (2,'kmc/test/key130',3,X'01',1,1,12,12,16,X'000000000000000000000001',19,X'00000000000000000000000000000000000000',1,5,0,0,44,1,0); +INSERT INTO security_associations (spi,ekid,sa_state,ecs,est,ast,shivf_len,iv_len,stmacf_len,iv,abm_len,abm,arsnw,arsn_len,tfvn,scid,vcid,mapid) +VALUES (2,'kmc/test/key130',3,X'01',1,1,12,12,16,X'000000000000000000000001',19,X'00000000000000000000000000000000000000',5,0,0,44,1,0); -- SA 3 - OPERATIONAL; ENC + AUTH - ARSNW:5; AES-GCM; IV:00...01; IV-len:12; MAC-len:16; Key-ID: 130, SCID 44, VC-1 -INSERT INTO security_associations (spi,ekid,sa_state,ecs,est,ast,shivf_len,iv_len,stmacf_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len,tfvn,scid,vcid,mapid) -VALUES (3,'kmc/test/key130',3,X'01',1,1,12,12,16,X'000000000000000000000001',19,X'00000000000000000000000000000000000000',1,5,0,0,44,2,0); +INSERT INTO security_associations (spi,ekid,sa_state,ecs,est,ast,shivf_len,iv_len,stmacf_len,iv,abm_len,abm,arsnw,arsn_len,tfvn,scid,vcid,mapid) +VALUES (3,'kmc/test/key130',3,X'01',1,1,12,12,16,X'000000000000000000000001',19,X'00000000000000000000000000000000000000',5,0,0,44,2,0); -- SA 4 - OPERATIONAL; AUTH Only - ARSNW:5; AES-GCM; IV:00...01; IV-len:12; MAC-len:16; Key-ID: 130, SCID 44, VC-3 -INSERT INTO security_associations (spi,ekid,sa_state,ecs,est,ast,shivf_len,iv_len,stmacf_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len,tfvn,scid,vcid,mapid) -VALUES (4,'kmc/test/key130',3,X'01',0,1,12,12,16,X'000000000000000000000001',1024,X'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',5,0,0,44,3,0); -- SCID 44 (MMT) Security Associations AESCMAC Authentication Only -- -- SA 5 - OPERATIONAL; AUTH Only - ARSNW:5; None/AESCMAC ; IV:00...01; IV-len:12; MAC-len:16; Key-ID: 130, SCID 44, VC-7 -INSERT INTO security_associations (spi,akid,sa_state,ecs,acs,est,ast,shivf_len,shsnf_len,stmacf_len,arsn,abm_len,abm,arsnw_len,arsnw,arsn_len,tfvn,scid,vcid,mapid) -VALUES (5,'kmc/test/key130',3,X'00',X'01',0,1,0,4,16,X'00000001',1024,X'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',5,4,0,44,7,0); diff --git a/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb_unit_test_security_associations.sql b/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb_unit_test_security_associations.sql index 3dcba0ed..2a5a990c 100644 --- a/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb_unit_test_security_associations.sql +++ b/src/crypto_sadb/sadb_mariadb_admin_scripts/create_sadb_unit_test_security_associations.sql @@ -1,33 +1,33 @@ USE sadb; -- SA 1 - CLEAR MODE -INSERT INTO security_associations (spi,sa_state,est,ast,arsn_len,arsn,arsnw_len,arsnw,tfvn,scid,vcid,mapid) -VALUES (1,3,0,0,1,X'0000000000000000000000000000000000000000',1,X'05',0,3,0,0); +INSERT INTO security_associations (spi,sa_state,est,ast,arsn_len,arsn,arsnw,tfvn,scid,vcid,mapid) +VALUES (1,3,0,0,1,X'0000000000000000000000000000000000000000',5,0,3,0,0); -- SA 2 - KEYED; ARSNW:5; AES-GCM; IV:00...00; IV-len:12; MAC-len:16; Key-ID: 128 -INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len) -VALUES (2,128,2,1,1,12,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',1,X'05',11); +INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw,arsn_len) +VALUES (2,128,2,1,1,12,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',5,11); -- SA 3 - KEYED; ARSNW:5; AES-GCM; IV:00...00; IV-len:12; MAC-len:16; Key-ID: 129 -INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,stmacf_len,iv_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len) -VALUES (3,129,2,1,1,12,16,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',1,X'05',11); +INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,stmacf_len,iv_len,iv,abm_len,abm,arsnw,arsn_len) +VALUES (3,129,2,1,1,12,16,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',5,11); -- SA 4 - KEYED; ARSNW:5; AES-GCM; IV:00...00; IV-len:12; MAC-len:16; Key-ID: 130 -INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len,tfvn,scid,vcid,mapid) -VALUES (4,130,2,1,1,12,12,X'000000000000000000000001',20,X'0000000000000000000000000000000000000000',1,X'05',11,0,3,0,0); +INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw,arsn_len,tfvn,scid,vcid,mapid) +VALUES (4,130,2,1,1,12,12,X'000000000000000000000001',20,X'0000000000000000000000000000000000000000',5,11,0,3,0,0); -- SA 5 - KEYED; ARSNW:5; AES-GCM; IV:00...00; IV-len:12; MAC-len:16; Key-ID: 131 -INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len) -VALUES (5,131,2,1,1,12,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',1,X'05',11); +INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw,arsn_len) +VALUES (5,131,2,1,1,12,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',5,11); -- SA 6 - UNKEYED; ARSNW:5; AES-GCM; IV:00...00; IV-len:12; MAC-len:16; Key-ID: - -INSERT INTO security_associations (spi,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len) -VALUES (6,1,1,1,12,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',1,X'05',11); +INSERT INTO security_associations (spi,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw,arsn_len) +VALUES (6,1,1,1,12,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',5,11); -- SA 7 - KEYED; ARSNW:5; AES-GCM; IV:00...00; IV-len:12; MAC-len:16; Key-ID: 130 -INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw_len,arsnw,arsn_len,tfvn,scid,vcid,mapid) -VALUES (7,130,2,1,1,12,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',1,X'05',11,0,3,1,0); +INSERT INTO security_associations (spi,ekid,sa_state,est,ast,shivf_len,iv_len,iv,abm_len,abm,arsnw,arsn_len,tfvn,scid,vcid,mapid) +VALUES (7,130,2,1,1,12,12,X'000000000000000000000000',20,X'0000000000000000000000000000000000000000',5,11,0,3,1,0); -- SA 8 - CLEAR MODE -INSERT INTO security_associations (spi,sa_state,est,ast,arsn_len,arsn,arsnw_len,arsnw,tfvn,scid,vcid,mapid) -VALUES (8,3,0,0,1,X'0000000000000000000000000000000000000000',1,X'05',0,3,1,0); +INSERT INTO security_associations (spi,sa_state,est,ast,arsn_len,arsn,arsnw,tfvn,scid,vcid,mapid) +VALUES (8,3,0,0,1,X'0000000000000000000000000000000000000000',5,0,3,1,0); diff --git a/src/src_cryptography/src_kmc_crypto_service/cryptography_interface_kmc_crypto_service.template.c b/src/src_cryptography/src_kmc_crypto_service/cryptography_interface_kmc_crypto_service.template.c index aae6ab24..ba693959 100644 --- a/src/src_cryptography/src_kmc_crypto_service/cryptography_interface_kmc_crypto_service.template.c +++ b/src/src_cryptography/src_kmc_crypto_service/cryptography_interface_kmc_crypto_service.template.c @@ -1312,9 +1312,12 @@ int32_t cryptography_get_acs_algo(int8_t algo_enum) int32_t algo = CRYPTO_LIB_ERR_UNSUPPORTED_ACS; // All valid algo enums will be positive switch (algo_enum) { - // case CRYPTO_MAC_CMAC_AES256: - // algo = GCRY_MAC_CMAC_AES; - // break; + case CRYPTO_MAC_CMAC_AES256: + return CRYPTO_MAC_CMAC_AES256; + case CRYPTO_MAC_HMAC_SHA256: + return CRYPTO_MAC_HMAC_SHA256; + case CRYPTO_MAC_HMAC_SHA512: + return CRYPTO_MAC_HMAC_SHA512; default: #ifdef DEBUG @@ -1336,9 +1339,8 @@ int32_t cryptography_get_ecs_algo(int8_t algo_enum) int32_t algo = CRYPTO_LIB_ERR_UNSUPPORTED_ECS; // All valid algo enums will be positive switch (algo_enum) { - // case CRYPTO_MAC_CMAC_AES256: - // algo = GCRY_MAC_CMAC_AES; - // break; + case CRYPTO_CIPHER_AES256_GCM: + return CRYPTO_CIPHER_AES256_GCM; default: #ifdef DEBUG diff --git a/src/src_main/crypto_print.c b/src/src_main/crypto_print.c index 69fd65a5..16d4a4e4 100644 --- a/src/src_main/crypto_print.c +++ b/src/src_main/crypto_print.c @@ -244,8 +244,8 @@ void Crypto_saPrint(SecurityAssociation_t* sa) printf("\n"); } - printf("\t arsnw_len = 0x%02x \n", sa->arsnw_len); - printf("\t arsnw = 0x%d \n", sa->arsnw); + printf("\t arsnw_len = %d \n", sa->arsnw_len); + printf("\t arsnw = %d \n", sa->arsnw); } /** diff --git a/src/src_mysql/sadb_routine_mariadb.template.c b/src/src_mysql/sadb_routine_mariadb.template.c index 7848f52a..fd80e59a 100644 --- a/src/src_mysql/sadb_routine_mariadb.template.c +++ b/src/src_mysql/sadb_routine_mariadb.template.c @@ -47,12 +47,12 @@ static int32_t finish_with_error(MYSQL *con, int err); static const char* SQL_SADB_GET_SA_BY_SPI = "SELECT " "spi,ekid,akid,sa_state,tfvn,scid,vcid,mapid,lpid,est,ast,shivf_len,shsnf_len,shplf_len,stmacf_len,ecs_len,HEX(ecs)" - ",HEX(iv),iv_len,acs_len,HEX(acs),abm_len,HEX(abm),arsn_len,HEX(arsn),arsnw_len,HEX(arsnw)" + ",HEX(iv),iv_len,acs_len,HEX(acs),abm_len,HEX(abm),arsn_len,HEX(arsn),arsnw" " FROM security_associations WHERE spi='%d'"; static const char* SQL_SADB_GET_SA_BY_GVCID = "SELECT " "spi,ekid,akid,sa_state,tfvn,scid,vcid,mapid,lpid,est,ast,shivf_len,shsnf_len,shplf_len,stmacf_len,ecs_len,HEX(ecs)" - ",HEX(iv),iv_len,acs_len,HEX(acs),abm_len,HEX(abm),arsn_len,HEX(arsn),arsnw_len,HEX(arsnw)" + ",HEX(iv),iv_len,acs_len,HEX(acs),abm_len,HEX(abm),arsn_len,HEX(arsn),arsnw" " FROM security_associations WHERE tfvn='%d' AND scid='%d' AND vcid='%d' AND mapid='%d' AND sa_state='%d'"; static const char* SQL_SADB_UPDATE_IV_ARC_BY_SPI = "UPDATE security_associations" @@ -479,11 +479,6 @@ static int32_t parse_sa_from_mysql_query(char* query, SecurityAssociation_t** se continue; } // if(strcmp(field_names[i],"HEX(arsn)")==0){convert_hexstring_to_byte_array(row[i],sa->arsn);continue;} - if (strcmp(field_names[i], "arsnw_len") == 0) - { - sa->arsnw_len = atoi(row[i]); - continue; - } if (strcmp(field_names[i], "arsnw") == 0) { sa->arsnw = atoi(row[i]); @@ -504,6 +499,9 @@ static int32_t parse_sa_from_mysql_query(char* query, SecurityAssociation_t** se convert_hexstring_to_byte_array(ecs_byte_str, sa->ecs); convert_hexstring_to_byte_array(acs_byte_str, sa->acs); + //arsnw_len is not necessary for mariadb interface, putty dummy/default value for prints. + sa->arsnw_len = 1; + *security_association = sa; mysql_free_result(result);