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 belt-hash
Commits
f01d6a9b
Commit
f01d6a9b
authored
2 months ago
by
Тур Тимофей Владимирович
Browse files
Options
Download
Patches
Plain Diff
hello printing
parent
a6ed0385
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/ak_belt_hash.c
+30
-8
source/ak_belt_hash.c
with
30 additions
and
8 deletions
+30
-8
source/ak_belt_hash.c
+
30
−
8
View file @
f01d6a9b
...
...
@@ -6,6 +6,7 @@
/* ----------------------------------------------------------------------------------------------- */
#include
<libakrypt-internal.h>
#include
<stdio.h>
//)))
//---------------------------------------------------------
//----------------------belt-block-------------------------
...
...
@@ -323,12 +324,20 @@ static int ak_hash_context_belt_hash_clean( ak_pointer bctx ) {
if
((
!
size
)
||
(
in
==
NULL
))
return
ak_error_ok
;
if
(
size
&
0x1F
)
return
ak_error_message
(
ak_error_wrong_length
,
__func__
,
"data length is not a multiple of the length of the block"
);
printf
(
"
\n
1: %s
\n
%i
\n
%s
\n
"
,
ak_ptr_to_hexstr
(
cx
->
h
,
sizeof
(
cx
->
h
),
ak_false
),
size
,
ak_ptr_to_hexstr
(
in
,
size
,
ak_false
));
// обновить длину
carry
=
(
cx
->
ls
[
0
]
+=
carry
)
<
carry
;
carry
=
(
cx
->
ls
[
1
]
+=
carry
)
<
carry
;
carry
=
(
cx
->
ls
[
2
]
+=
carry
)
<
carry
;
cx
->
ls
[
3
]
+=
carry
;
printf
(
"
\n
2: %i
\n
"
,
cx
->
ls
[
0
]);
// накопленных данных на этот момент не предполагается,
// потому сразу в цикл по блокам
// цикл по полным блокам
...
...
@@ -345,6 +354,8 @@ static int ak_hash_context_belt_hash_clean( ak_pointer bctx ) {
count
-=
32
;
}
printf
(
"
\n
3: %i
\n
"
,
count
);
return
ak_error_ok
;
}
...
...
@@ -353,7 +364,7 @@ static int ak_hash_context_belt_hash_clean( ak_pointer bctx ) {
const
size_t
out_size
)
{
ak_belt_hash
cx
=
(
ak_belt_hash
)
bctx
;
const
ak_uint8
*
dt
=
(
const
ak_uint8
*
)
in
;
//
const ak_uint8* dt = (const ak_uint8*) in;
//ak_uint8 m[32];
struct
belt_hash
bx
[
1
];
/* структура для хранения копии текущего состояния контекста */
ak_uint32
carry
=
size
<<
3
;
...
...
@@ -365,15 +376,20 @@ static int ak_hash_context_belt_hash_clean( ak_pointer bctx ) {
if
(
size
>=
32
)
return
ak_error_message
(
ak_error_wrong_length
,
__func__
,
"input length is too huge"
);
// обновить длину
carry
=
(
cx
->
ls
[
0
]
+=
carry
)
<
carry
;
carry
=
(
cx
->
ls
[
1
]
+=
carry
)
<
carry
;
carry
=
(
cx
->
ls
[
2
]
+=
carry
)
<
carry
;
cx
->
ls
[
3
]
+=
carry
;
memcpy
(
bx
,
cx
,
sizeof
(
struct
belt_hash
));
printf
(
"
\n
4: %s
\n
%i
\n
%s
\n
"
,
ak_ptr_to_hexstr
(
bx
->
h
,
sizeof
(
bx
->
h
),
ak_false
),
size
,
ak_ptr_to_hexstr
(
in
,
size
,
ak_false
));
// обновить длину
carry
=
(
bx
->
ls
[
0
]
+=
carry
)
<
carry
;
carry
=
(
bx
->
ls
[
1
]
+=
carry
)
<
carry
;
carry
=
(
bx
->
ls
[
2
]
+=
carry
)
<
carry
;
bx
->
ls
[
3
]
+=
carry
;
printf
(
"
\n
5: %i
\n
"
,
bx
->
ls
[
0
]);
/* при финализации мы изменяем копию существующей структуры */
...
...
@@ -389,8 +405,14 @@ static int ak_hash_context_belt_hash_clean( ak_pointer bctx ) {
beltCompress2
(
bx
->
ls
+
4
,
bx
->
h
,
(
ak_uint32
*
)
bx
->
block
,
bx
->
stack
);
}
printf
(
"
\n
6: %s
\n
"
,
ak_ptr_to_hexstr
(
bx
->
block
,
32
,
ak_false
));
beltCompress
(
bx
->
h
,
bx
->
ls
,
bx
->
stack
);
printf
(
"
\n
7: %s
\n
"
,
ak_ptr_to_hexstr
(
bx
->
h
,
32
,
ak_false
));
// ak_hash_context_streebog_g( &sx, sx.n, m );
// ak_hash_context_streebog_add( &sx, size << 3 );
// ak_hash_context_streebog_sadd( &sx, m );
...
...
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