diff --git a/aktool/aktool_key.c b/aktool/aktool_key.c index 23d72b5a23a8eaf3d5eb39801ac1d800497bdf8a..37e3dc4d22c8253f54bf828d08468378f1a6a076 100644 --- a/aktool/aktool_key.c +++ b/aktool/aktool_key.c @@ -870,6 +870,7 @@ /* ----------------------------------------------------------------------------------------------- */ int aktool_key_new_blom_pairwise( void ) { + ssize_t len = 0; struct blomkey abonent; int exitcode = EXIT_FAILURE; @@ -943,7 +944,8 @@ aktool_error(_("incorrect key file creation")); goto labex1; } - if( ak_file_write( &fs, key, abonent.count ) != abonent.count ) { + len = ak_file_write( &fs, key, abonent.count ); + if(( len < 0 ) || ( (size_t)len != abonent.count )) { aktool_error(_("incorrect write to %s%s%s file"), ak_error_get_start_string(), ki.os_file, ak_error_get_end_string( )); } diff --git a/examples/tests/test-asn1-keys.c b/examples/tests/test-asn1-keys.c index 0a146309f23ca6c87e32c0f5a87d4026dc2fc9a5..6860f1016e3f2e68443e5ebfbb3e75ce9ba87fb8 100644 --- a/examples/tests/test-asn1-keys.c +++ b/examples/tests/test-asn1-keys.c @@ -191,20 +191,22 @@ /* --------------------------------------------------------------------------------------------- */ int signkey_test( ak_oid curvoid ) { - int result = EXIT_SUCCESS; - ak_oid oid = NULL; - ak_uint8 testkey[64] = { + int result = EXIT_SUCCESS; + ak_oid oid = NULL; + ak_uint8 testkey[64] = { 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x27, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x38, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xf1, 0xe2, 0xd3, 0xc4, 0xb5, 0xa6, 0x97, 0x88, 0x79, 0x6a, 0x5b, 0x4c, 0x3d, 0x2e, 0x1f, 0x00 }; - ak_uint8 sign[128]; - char filename[128], tname[256]; - struct signkey skey, lkey; - struct verifykey vkey; - struct random generator; - - ak_random_create_lcg( &generator ); + ak_uint8 sign[128]; + char filename[128], tname[256]; + struct signkey skey, lkey; + struct verifykey vkey; + struct random generator; + + ak_random_create_lcg( &generator ); + /* добавляем случайность в вырабатываемую ключевую информацию */ + ak_random_ptr( &generator, testkey, 64 ); if(( curvoid->engine == identifier ) && ( curvoid->mode == wcurve_params )) { ak_signkey_create( &skey, (ak_wcurve)curvoid->data ); diff --git a/source/ak_asn1_keys.c b/source/ak_asn1_keys.c index cc0bd84aff57474b5375f01043b324cc7b84b61c..3c42479d9bd47a8ffc3a01eb25b2b74593a31454 100644 --- a/source/ak_asn1_keys.c +++ b/source/ak_asn1_keys.c @@ -1329,7 +1329,11 @@ return ak_error_message( ak_error_wrong_oid, __func__, "incorrect value of content identifier" ); /* определяем тип контента ( нас интересует только хранение секретных ключей ) */ - switch(( content_type = ((ak_uint64) oid->data )&0xFF )) { + #ifdef AK_SIZEOF_VOID_P_IS_8 + switch(( content_type = ((ak_uint64)oid->data)&0xFF )) { + #else + switch(( content_type = ((ak_uint32)oid->data)&0xFF )) { + #endif case symmetric_key_content: case secret_key_content: break; diff --git a/source/ak_file.c b/source/ak_file.c index 90334a10f3c6b9fbe02823d452330bbec7a95587..0711a69d22ce944626ffef491ec330488dfb9092 100644 --- a/source/ak_file.c +++ b/source/ak_file.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------------------------- */ -/* Copyright (c) 2004 - 2020, 2022 - 2023 by Axel Kenzo, axelkenzo@mail.ru */ +/* Copyright (c) 2004 - 2020, 2022 - 2024 by Axel Kenzo, axelkenzo@mail.ru */ /* */ /* Файл ak_file.с */ /* ----------------------------------------------------------------------------------------------- */ @@ -242,7 +242,7 @@ } else localbuffer[off++] = ch; /* выходим из цикла если процедура проверки нарушена */ if( error != ak_error_ok ) return error; - } while( ch != EOF ); + } while( 1 ); /* удалено: ch != EOF */ close( fd ); return error; diff --git a/source/ak_mgm.c b/source/ak_mgm.c index 7154b662686d0dae002efe71b5a9bfa0e173104c..9c1f1da7f121b7c55a17795621bb0040267d6d56 100644 --- a/source/ak_mgm.c +++ b/source/ak_mgm.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------------------------- */ -/* Copyright (c) 2017 - 2021 by Axel Kenzo, axelkenzo@mail.ru */ +/* Copyright (c) 2017 - 2021, 2024 by Axel Kenzo, axelkenzo@mail.ru */ /* */ /* Файл ak_mgm.c */ /* - содержит функции, реализующие аутентифицированное шифрование @@ -251,10 +251,12 @@ astep128( temp.b ); } else { /* теперь тоже самое, но для 64-битного шифра */ + /* для 32х битной архитектуры нижеследующее сравнение бессмысленно */ + #ifdef AK_SIZEOF_VOID_P_IS_8 if(( ctx->abitlen > 0xFFFFFFFF ) || ( ctx->pbitlen > 0xFFFFFFFF )) return ak_error_message( ak_error_overflow, __func__, "using an algorithm with very long data" ); - + #endif #ifdef AK_LITTLE_ENDIAN temp.w[0] = (ak_uint32) ctx->pbitlen; temp.w[1] = (ak_uint32) ctx->abitlen; @@ -681,7 +683,8 @@ длины корректны для Магмы и для Кузнечика на 64-х битной архитектуре много может быть только для Магмы => проверяем */ - if(( sizeof ( ak_pointer ) > 4 ) && ( bsize != 16 )) { + #ifdef AK_SIZEOF_VOID_P_IS_8 + if( bsize != 16 ) { if( aval > 0x0000000100000000LL ) return ak_error_message( ak_error_wrong_length, __func__, "length of assosiated data is very large"); if( pval > 0x0000000100000000LL ) return ak_error_message( ak_error_wrong_length, __func__, @@ -689,7 +692,9 @@ if( temp > 0x0000000100000000LL ) return ak_error_message( ak_error_wrong_length, __func__, "total length of assosiated and plain data is very large"); } - + #else + (void) bsize; + #endif return ak_error_ok; }