Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Николаев Александр Александрович
libakrypt-0.x-parts-implementation
Commits
590492c3
Commit
590492c3
authored
9 months ago
by
Нестеренко Алексей Юрьевич
Browse files
Options
Download
Patches
Plain Diff
Добавлен тестовый пример
parent
3bb0b885
master
0.9.14
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
CMakeLists.txt
examples/tests/test-kuznechik01.c
+45
-0
examples/tests/test-kuznechik01.c
source/ak_htable.c
+4
-0
source/ak_htable.c
with
50 additions
and
0 deletions
+50
-0
CMakeLists.txt
+
1
−
0
View file @
590492c3
...
...
@@ -276,6 +276,7 @@ set ( ARITHMETIC_TESTS_LIST
kdf-state
hash01
hash02
kuznechik01
)
if
(
AK_TESTS_GMP
)
...
...
This diff is collapsed.
Click to expand it.
examples/tests/test-kuznechik01.c
0 → 100644
+
45
−
0
View file @
590492c3
/* ----------------------------------------------------------------------------------------------- */
/* тест развертки раундовых ключей */
#include
<stdio.h>
#include
<libakrypt.h>
/* ----------------------------------------------------------------------------------------------- */
int
main
(
void
)
{
/* тестовый ключ из ГОСТ Р 34.13-2015, приложение А.1
ak_uint8 keyAnnexA[32] = {
0xef,0xcd,0xab,0x89,0x67,0x45,0x23,0x01,0x10,0x32,0x54,0x76,0x98,0xba,0xdc,0xfe,
0x77,0x66,0x55,0x44,0x33,0x22,0x11,0x00,0xff,0xee,0xdd,0xcc,0xbb,0xaa,0x99,0x88
}; */
ak_uint8
keyExample
[
32
]
=
{
0x49
,
0x45
,
0x20
,
0xce
,
0x26
,
0x51
,
0x8e
,
0xfd
,
0x7d
,
0x87
,
0x6d
,
0xd6
,
0xea
,
0xac
,
0x32
,
0x9e
,
0x81
,
0xb7
,
0x37
,
0x8a
,
0x9f
,
0xbc
,
0x0e
,
0xae
,
0x12
,
0x24
,
0x06
,
0x63
,
0x52
,
0x76
,
0xbe
,
0x72
};
int
i
,
j
=
0
;
struct
bckey
key
;
ak_uint64
*
round
=
NULL
;
/* инициализируем библиотеку с максимальным уровнем аудита */
ak_log_set_level
(
ak_log_maximum
);
ak_libakrypt_create
(
ak_function_log_stderr
);
/* создаем контекст секретного ключа */
ak_bckey_create_kuznechik
(
&
key
);
/* присваиваем значение, например так ak_bckey_set_key( &key, keyAnnexA, 32 ); */
ak_bckey_set_key
(
&
key
,
keyExample
,
32
);
/* выводим выработанные раундовые ключи */
round
=
(
ak_uint64
*
)
key
.
key
.
data
;
printf
(
" 15 9: 8 0
\n
--------------------------------------
\n
"
);
for
(
i
=
0
,
j
=
1
;
i
<
20
;
j
++
,
i
+=
2
)
{
printf
(
"%2d| %016llx:%016llx
\n
"
,
j
,
round
[
1
+
i
]
^
round
[
41
+
i
],
round
[
i
]
^
round
[
40
+
i
]
);
}
/* все уничтожаем */
ak_bckey_destroy
(
&
key
);
ak_libakrypt_destroy
();
return
EXIT_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
source/ak_htable.c
+
4
−
0
View file @
590492c3
...
...
@@ -5,6 +5,8 @@
/* ----------------------------------------------------------------------------------------------- */
#include
<libakrypt-base.h>
/* ----------------------------------------------------------------------------------------------- */
/* вспомогательные функции */
/* ----------------------------------------------------------------------------------------------- */
static
inline
ak_uint64
ak_uint64_ton
(
ak_uint64
x
)
{
#ifdef AK_BIG_ENDIAN
...
...
@@ -14,6 +16,8 @@
#endif
}
/* ----------------------------------------------------------------------------------------------- */
/* реализация основного функционала */
/* ----------------------------------------------------------------------------------------------- */
/*! @param kp Указатель на контекст пары (ключ:данные), не должен принимать значение, равное NULL
@param key Указатель на область памяти, содержащей ключевое значение; не должен быть равен NULL
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets