mirror of
https://github.com/kazu-yamamoto/crypton.git
synced 2024-10-04 15:57:47 +03:00
Update decaf to upstream commit '807a7e6'
* Don't use vector arithmetic in generic arch_32 * fix comments add/subtract
This commit is contained in:
parent
06dc3de5c4
commit
72c3fa0f6a
@ -10,37 +10,22 @@
|
||||
#define LIMB_PLACE_VALUE(i) 28
|
||||
|
||||
void cryptonite_gf_add_RAW (gf out, const gf a, const gf b) {
|
||||
for (unsigned int i=0; i<sizeof(*out)/sizeof(uint32xn_t); i++) {
|
||||
((uint32xn_t*)out)[i] = ((const uint32xn_t*)a)[i] + ((const uint32xn_t*)b)[i];
|
||||
}
|
||||
/*
|
||||
unsigned int i;
|
||||
for (i=0; i<sizeof(*out)/sizeof(out->limb[0]); i++) {
|
||||
for (unsigned int i=0; i<sizeof(*out)/sizeof(out->limb[0]); i++) {
|
||||
out->limb[i] = a->limb[i] + b->limb[i];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void cryptonite_gf_sub_RAW (gf out, const gf a, const gf b) {
|
||||
for (unsigned int i=0; i<sizeof(*out)/sizeof(uint32xn_t); i++) {
|
||||
((uint32xn_t*)out)[i] = ((const uint32xn_t*)a)[i] - ((const uint32xn_t*)b)[i];
|
||||
}
|
||||
/*
|
||||
unsigned int i;
|
||||
for (i=0; i<sizeof(*out)/sizeof(out->limb[0]); i++) {
|
||||
for (unsigned int i=0; i<sizeof(*out)/sizeof(out->limb[0]); i++) {
|
||||
out->limb[i] = a->limb[i] - b->limb[i];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void cryptonite_gf_bias (gf a, int amt) {
|
||||
uint32_t co1 = ((1ull<<28)-1)*amt, co2 = co1-amt;
|
||||
uint32x4_t lo = {co1,co1,co1,co1}, hi = {co2,co1,co1,co1};
|
||||
uint32x4_t *aa = (uint32x4_t*) a;
|
||||
aa[0] += lo;
|
||||
aa[1] += lo;
|
||||
aa[2] += hi;
|
||||
aa[3] += lo;
|
||||
for (unsigned int i=0; i<sizeof(*a)/sizeof(a->limb[0]); i++) {
|
||||
a->limb[i] += (i==sizeof(*a)/sizeof(a->limb[0])/2) ? co2 : co1;
|
||||
}
|
||||
}
|
||||
|
||||
void cryptonite_gf_weak_reduce (gf a) {
|
||||
|
@ -106,14 +106,14 @@ void cryptonite_gf_strong_reduce (gf a) {
|
||||
assert(word_is_zero(carry + scarry_0));
|
||||
}
|
||||
|
||||
/** Add two gf elements */
|
||||
/** Subtract two gf elements d=a-b */
|
||||
void cryptonite_gf_sub (gf d, const gf a, const gf b) {
|
||||
cryptonite_gf_sub_RAW ( d, a, b );
|
||||
cryptonite_gf_bias( d, 2 );
|
||||
cryptonite_gf_weak_reduce ( d );
|
||||
}
|
||||
|
||||
/** Subtract d = a-b */
|
||||
/** Add two field elements d = a+b */
|
||||
void cryptonite_gf_add (gf d, const gf a, const gf b) {
|
||||
cryptonite_gf_add_RAW ( d, a, b );
|
||||
cryptonite_gf_weak_reduce ( d );
|
||||
|
@ -6,7 +6,7 @@
|
||||
# (available at <git://git.code.sf.net/p/ed448goldilocks/code>).
|
||||
#
|
||||
# Project is synced with upstream commit
|
||||
# 'b29565fdfd654385b6d6e3257e60a7e94636057f'.
|
||||
# '807a7e67decbf8ccc10be862cdf9ae03653ffe70'.
|
||||
#
|
||||
# Notes about transformations applied:
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user