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-stb34
Commits
0627fc05
Commit
0627fc05
authored
2 months ago
by
Белов Никита Сергеевич
Browse files
Options
Download
Patches
Plain Diff
Upload New File
parent
749b09e6
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/tests/test-belt-hash.c
+79
-0
examples/tests/test-belt-hash.c
with
79 additions
and
0 deletions
+79
-0
examples/tests/test-belt-hash.c
0 → 100644
+
79
−
0
View file @
0627fc05
#include
<stdio.h>
#include
<libakrypt.h>
static
int
ak_function_my_audit
(
const
char
*
message
)
{
if
(
message
!=
NULL
)
fprintf
(
stderr
,
"%s
\n
"
,
message
);
return
ak_error_ok
;
}
int
main
()
{
int
error
=
ak_error_ok
;
/* Инициализация криптографической библиотеки */
int
exitstatus
=
EXIT_FAILURE
;
/* Контекст для вычисления хеширования */
struct
hash
hctx
;
ak_uint8
input1
[
13
]
=
{
0xB1
,
0x94
,
0xBA
,
0xC8
,
0x0A
,
0x08
,
0xF5
,
0x3B
,
0x36
,
0x6D
,
0x00
,
0x8E
,
0x58
};
ak_uint8
test_output1
[
32
]
=
{
0xAB
,
0xEF
,
0x97
,
0x25
,
0xD4
,
0xC5
,
0xA8
,
0x35
,
0x97
,
0xA3
,
0x67
,
0xD1
,
0x44
,
0x94
,
0xCC
,
0x25
,
0x42
,
0xF2
,
0x0F
,
0x65
,
0x9D
,
0xDF
,
0xEC
,
0xC9
,
0x61
,
0xA3
,
0xEC
,
0x55
,
0x0C
,
0xBA
,
0x8C
,
0x75
};
ak_uint32
output
[
8
];
if
(
ak_libakrypt_create
(
NULL
)
!=
ak_true
)
{
ak_libakrypt_destroy
();
return
EXIT_FAILURE
;
}
ak_hash_create_belt
(
&
hctx
);
ak_hash_ptr
(
&
hctx
,
input1
,
13
,
output
,
32
);
printf
(
"Test 1
\n
"
);
printf
(
"1: %s
\n
"
,
ak_ptr_to_hexstr
(
test_output1
,
sizeof
(
test_output1
),
ak_false
));
printf
(
"2: %s
\n\n
"
,
ak_ptr_to_hexstr
(
output
,
sizeof
(
output
),
ak_false
));
ak_uint8
input2
[
32
]
=
{
0xB1
,
0x94
,
0xBA
,
0xC8
,
0x0A
,
0x08
,
0xF5
,
0x3B
,
0x36
,
0x6D
,
0x00
,
0x8E
,
0x58
,
0x4A
,
0x5D
,
0xE4
,
0x85
,
0x04
,
0xFA
,
0x9D
,
0x1B
,
0xB6
,
0xC7
,
0xAC
,
0x25
,
0x2E
,
0x72
,
0xC2
,
0x02
,
0xFD
,
0xCE
,
0x0D
};
ak_uint8
test_output2
[
32
]
=
{
0x74
,
0x9E
,
0x4C
,
0x36
,
0x53
,
0xAE
,
0xCE
,
0x5E
,
0x48
,
0xDB
,
0x47
,
0x61
,
0x22
,
0x77
,
0x42
,
0xEB
,
0x6D
,
0xBE
,
0x13
,
0xF4
,
0xA8
,
0x0F
,
0x7B
,
0xEF
,
0xF1
,
0xA9
,
0xCF
,
0x8D
,
0x10
,
0xEE
,
0x77
,
0x86
};
ak_hash_ptr
(
&
hctx
,
input2
,
32
,
output
,
32
);
printf
(
"Test 2
\n
"
);
printf
(
"1: %s
\n
"
,
ak_ptr_to_hexstr
(
test_output2
,
sizeof
(
test_output2
),
ak_false
));
printf
(
"2: %s
\n\n
"
,
ak_ptr_to_hexstr
(
output
,
sizeof
(
output
),
ak_false
));
ak_uint8
input3
[
48
]
=
{
0xB1
,
0x94
,
0xBA
,
0xC8
,
0x0A
,
0x08
,
0xF5
,
0x3B
,
0x36
,
0x6D
,
0x00
,
0x8E
,
0x58
,
0x4A
,
0x5D
,
0xE4
,
0x85
,
0x04
,
0xFA
,
0x9D
,
0x1B
,
0xB6
,
0xC7
,
0xAC
,
0x25
,
0x2E
,
0x72
,
0xC2
,
0x02
,
0xFD
,
0xCE
,
0x0D
,
0x5B
,
0xE3
,
0xD6
,
0x12
,
0x17
,
0xB9
,
0x61
,
0x81
,
0xFE
,
0x67
,
0x86
,
0xAD
,
0x71
,
0x6B
,
0x89
,
0x0B
};
ak_uint8
test_output3
[
32
]
=
{
0x9D
,
0x02
,
0xEE
,
0x44
,
0x6F
,
0xB6
,
0xA2
,
0x9F
,
0xE5
,
0xC9
,
0x82
,
0xD4
,
0xB1
,
0x3A
,
0xF9
,
0xD3
,
0xE9
,
0x08
,
0x61
,
0xBC
,
0x4C
,
0xEF
,
0x27
,
0xCF
,
0x30
,
0x6B
,
0xFB
,
0x0B
,
0x17
,
0x4A
,
0x15
,
0x4A
};
ak_hash_ptr
(
&
hctx
,
input3
,
sizeof
(
input3
),
output
,
32
);
printf
(
"Test 3
\n
"
);
printf
(
"1: %s
\n
"
,
ak_ptr_to_hexstr
(
test_output3
,
sizeof
(
test_output3
),
ak_false
));
printf
(
"2: %s
\n
"
,
ak_ptr_to_hexstr
(
output
,
sizeof
(
output
),
ak_false
));
return
0
;
}
\ No newline at end of file
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