mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Change GF(2^128) API
from `r = op(a, b)` to `op(r, a, b)`
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
|
||||
* Copyright 2014-2024 The GmSSL Project. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
@@ -27,27 +27,20 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//typedef unsigned __int128 gf128_t;
|
||||
|
||||
// the least significant bit of lo is a_0, the most significant bit of hi is a_127
|
||||
// so x^7 + x^2 + x + 1 is 0x87
|
||||
typedef struct {
|
||||
uint64_t lo;
|
||||
uint64_t hi;
|
||||
} gf128_t;
|
||||
typedef uint64_t gf128_t[2];
|
||||
|
||||
void gf128_set_zero(gf128_t r);
|
||||
void gf128_set_one(gf128_t r);
|
||||
void gf128_add(gf128_t r, const gf128_t a, const gf128_t b);
|
||||
void gf128_mul(gf128_t r, const gf128_t a, const gf128_t b);
|
||||
void gf128_mul_by_2(gf128_t r, const gf128_t a);
|
||||
void gf128_from_bytes(gf128_t r, const uint8_t p[16]);
|
||||
void gf128_to_bytes(const gf128_t a, uint8_t p[16]);
|
||||
int gf128_from_hex(gf128_t r, const char *s);
|
||||
int gf128_equ_hex(const gf128_t a, const char *s);
|
||||
int gf128_print(FILE *fp, int fmt, int ind, const char *label, const gf128_t a);
|
||||
|
||||
// Note: send by value is comptabile with uint128_t and sse2
|
||||
gf128_t gf128_from_hex(const char *s);
|
||||
int gf128_equ_hex(gf128_t a, const char *s);
|
||||
gf128_t gf128_zero(void);
|
||||
gf128_t gf128_add(gf128_t a, gf128_t b);
|
||||
gf128_t gf128_mul(gf128_t a, gf128_t b);
|
||||
gf128_t gf128_mul2(gf128_t a);
|
||||
gf128_t gf128_from_bytes(const uint8_t p[16]);
|
||||
void gf128_to_bytes(gf128_t a, uint8_t p[16]);
|
||||
int gf128_print(FILE *fp, int fmt ,int ind, const char *label, gf128_t a);
|
||||
void gf128_print_bits(gf128_t a);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user