-
Notifications
You must be signed in to change notification settings - Fork 25
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 #140 from jargh/main
Extra P-256 functions for AWS-LC integration, popcount, basic P-384 scalar mul
- Loading branch information
Showing
48 changed files
with
157,673 additions
and
14 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
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,41 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0 | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Count number of set bits in a single 64-bit word (population count) | ||
// Input a; output function return | ||
// | ||
// extern uint64_t word_popcount (uint64_t a); | ||
// | ||
// Standard ARM ABI: X0 = a, returns X0 | ||
// ---------------------------------------------------------------------------- | ||
#include "_internal_s2n_bignum.h" | ||
|
||
S2N_BN_SYM_VISIBILITY_DIRECTIVE(word_popcount) | ||
S2N_BN_SYM_PRIVACY_DIRECTIVE(word_popcount) | ||
.text | ||
.balign 4 | ||
|
||
// Very similar to the traditional algorithm, e.g. Hacker's Delight 5-2 | ||
|
||
S2N_BN_SYMBOL(word_popcount): | ||
|
||
and x1, x0, #0xAAAAAAAAAAAAAAAA | ||
sub x0, x0, x1, lsr #1 | ||
|
||
bic x1, x0, #0x3333333333333333 | ||
and x0, x0, #0x3333333333333333 | ||
add x0, x0, x1, lsr #2 | ||
|
||
add x0, x0, x0, lsr #4 | ||
and x0, x0, #0x0F0F0F0F0F0F0F0F | ||
|
||
mov x1, #0x101010101010101 | ||
mul x0, x0, x1 | ||
lsr x0, x0, #56 | ||
|
||
ret | ||
|
||
#if defined(__linux__) && defined(__ELF__) | ||
.section .note.GNU-stack,"",%progbits | ||
#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
Oops, something went wrong.