-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #610 from JohnSanpe/feat-md5
Feat md5
- Loading branch information
Showing
14 changed files
with
512 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
/sha-bandwidth | ||
/sha | ||
/crypto-bandwidth | ||
/crypto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
# | ||
# Copyright(c) 2023 John Sanpe <sanpeqf@gmail.com> | ||
# | ||
|
||
add_executable(crypto-bandwidth bandwidth.c) | ||
target_link_libraries(crypto-bandwidth bfdev) | ||
add_test(crypto-bandwidth crypto-bandwidth) | ||
|
||
add_executable(crypto utils.c) | ||
target_link_libraries(crypto bfdev) | ||
|
||
add_test(sha1 crypto "helloworld") | ||
add_test(sha224 crypto -l "helloworld") | ||
add_test(sha256 crypto -e "helloworld") | ||
add_test(md5 crypto -m "helloworld") | ||
|
||
if(${CMAKE_PROJECT_NAME} STREQUAL "bfdev") | ||
install(FILES | ||
bandwidth.c | ||
utils.c | ||
DESTINATION | ||
${CMAKE_INSTALL_DOCDIR}/examples/crypto | ||
) | ||
|
||
install(TARGETS | ||
crypto | ||
crypto-bandwidth | ||
DESTINATION | ||
${CMAKE_INSTALL_DOCDIR}/bin | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
/* | ||
* Copyright(c) 2024 John Sanpe <sanpeqf@gmail.com> | ||
*/ | ||
|
||
#ifndef _BFDEV_CRYPTO_SHA1_H_ | ||
#define _BFDEV_CRYPTO_SHA1_H_ | ||
|
||
#include <bfdev/config.h> | ||
#include <bfdev/types.h> | ||
#include <bfdev/bitops.h> | ||
#include <bfdev/unaligned.h> | ||
|
||
#define BFDEV_CHACHA_BLEND(b, A, B, C, D, E) \ | ||
b[A] += b[B]; b[C] = bfdev_rol32(b[C] ^ b[D], E) | ||
static inline void | ||
bfdev_chacha_permute(uint32_t *block, unsigned int rounds) | ||
{ | ||
unsigned int count; | ||
|
||
for (count = 0; count < rounds; count += 2) { | ||
BFDEV_CHACHA_BLEND(block, 0, 4, 12, 0, 16); | ||
BFDEV_CHACHA_BLEND(block, 1, 5, 13, 1, 16); | ||
BFDEV_CHACHA_BLEND(block, 2, 6, 14, 2, 16); | ||
BFDEV_CHACHA_BLEND(block, 3, 7, 15, 3, 16); | ||
|
||
BFDEV_CHACHA_BLEND(block, 8, 12, 4, 8, 12); | ||
BFDEV_CHACHA_BLEND(block, 9, 13, 5, 9, 12); | ||
BFDEV_CHACHA_BLEND(block, 10, 14, 6, 10, 12); | ||
BFDEV_CHACHA_BLEND(block, 11, 15, 7, 11, 12); | ||
|
||
BFDEV_CHACHA_BLEND(block, 0, 4, 12, 0, 8); | ||
BFDEV_CHACHA_BLEND(block, 1, 5, 13, 1, 8); | ||
BFDEV_CHACHA_BLEND(block, 2, 6, 14, 2, 8); | ||
BFDEV_CHACHA_BLEND(block, 3, 7, 15, 3, 8); | ||
|
||
BFDEV_CHACHA_BLEND(block, 8, 12, 4, 8, 7); | ||
BFDEV_CHACHA_BLEND(block, 9, 13, 5, 9, 7); | ||
BFDEV_CHACHA_BLEND(block, 10, 14, 6, 10, 7); | ||
BFDEV_CHACHA_BLEND(block, 11, 15, 7, 11, 7); | ||
|
||
BFDEV_CHACHA_BLEND(block, 0, 5, 15, 0, 16); | ||
BFDEV_CHACHA_BLEND(block, 1, 6, 12, 1, 16); | ||
BFDEV_CHACHA_BLEND(block, 2, 7, 13, 2, 16); | ||
BFDEV_CHACHA_BLEND(block, 3, 4, 14, 3, 16); | ||
|
||
BFDEV_CHACHA_BLEND(block, 10, 15, 5, 10, 12); | ||
BFDEV_CHACHA_BLEND(block, 11, 12, 6, 11, 12); | ||
BFDEV_CHACHA_BLEND(block, 8, 13, 7, 8, 12); | ||
BFDEV_CHACHA_BLEND(block, 9, 14, 4, 9, 12); | ||
|
||
BFDEV_CHACHA_BLEND(block, 0, 5, 15, 0, 8); | ||
BFDEV_CHACHA_BLEND(block, 1, 6, 12, 1, 8); | ||
BFDEV_CHACHA_BLEND(block, 2, 7, 13, 2, 8); | ||
BFDEV_CHACHA_BLEND(block, 3, 4, 14, 3, 8); | ||
|
||
BFDEV_CHACHA_BLEND(block, 10, 15, 5, 10, 7); | ||
BFDEV_CHACHA_BLEND(block, 11, 12, 6, 11, 7); | ||
BFDEV_CHACHA_BLEND(block, 8, 13, 7, 8, 7); | ||
BFDEV_CHACHA_BLEND(block, 9, 14, 4, 9, 7); | ||
} | ||
} |
Oops, something went wrong.