-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This debug log is folded away in production builds Signed-off-by: Stephan Mueller <[email protected]>
- Loading branch information
1 parent
9687d0f
commit 499b629
Showing
10 changed files
with
238 additions
and
18 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,52 @@ | ||
/* | ||
* Copyright (C) 2023, Stephan Mueller <[email protected]> | ||
* | ||
* License: see LICENSE file in root directory | ||
* | ||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF | ||
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH | ||
* DAMAGE. | ||
*/ | ||
|
||
#include "binhexbin.h" | ||
#include "kyber_debug.h" | ||
|
||
void kyber_print_buffer(const uint8_t *buffer, const size_t bufferlen, | ||
const char *explanation) | ||
{ | ||
bin2print(buffer, bufferlen, stdout, explanation); | ||
} | ||
|
||
void kyber_print_polyvec(polyvec *polyvec_val, const char *explanation) | ||
{ | ||
unsigned int i, j; | ||
|
||
printf("%s", explanation); | ||
for (i = 0; i < LC_KYBER_K; i++) { | ||
printf("\nK(%u) x N: ", i); | ||
for (j = 0; j < LC_KYBER_N; j++) { | ||
printf("%d ", polyvec_val->vec[i].coeffs[j]); | ||
} | ||
} | ||
printf("\n"); | ||
} | ||
|
||
void kyber_print_poly(poly *vec, const char *explanation) | ||
{ | ||
unsigned int i; | ||
|
||
printf("%s\n", explanation); | ||
for (i = 0; i < LC_KYBER_N; i++) { | ||
printf("%d ", vec->coeffs[i]); | ||
} | ||
printf("\n"); | ||
} |
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,74 @@ | ||
/* | ||
* Copyright (C) 2023, Stephan Mueller <[email protected]> | ||
* | ||
* License: see LICENSE file in root directory | ||
* | ||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF | ||
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH | ||
* DAMAGE. | ||
*/ | ||
|
||
#ifndef KYBER_DEBUG_H | ||
#define KYBER_DEBUG_H | ||
|
||
#include "kyber_poly.h" | ||
#include "kyber_polyvec.h" | ||
#include "lc_kyber.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifdef LC_KYBER_DEBUG | ||
|
||
/* Disable selftests */ | ||
#define LC_KYBER_TEST_INIT 1 | ||
|
||
void kyber_print_buffer(const uint8_t *buffer, const size_t bufferlen, | ||
const char *explanation); | ||
void kyber_print_polyvec(polyvec *polyvec_val, const char *explanation); | ||
void kyber_print_poly(poly *vec, const char *explanation); | ||
|
||
#else /* LC_KYBER_DEBUG */ | ||
|
||
/* Enable selftests */ | ||
#define LC_KYBER_TEST_INIT 0 | ||
|
||
static inline void kyber_print_buffer(const uint8_t *buffer, | ||
const size_t bufferlen, | ||
const char *explanation) | ||
{ | ||
(void)buffer; | ||
(void)bufferlen; | ||
(void)explanation; | ||
} | ||
|
||
static inline void kyber_print_polyvec(polyvec *polyvec_val, | ||
const char *explanation) | ||
{ | ||
(void)polyvec_val; | ||
(void)explanation; | ||
} | ||
|
||
static inline void kyber_print_poly(poly *vec, const char *explanation) | ||
{ | ||
(void)vec; | ||
(void)explanation; | ||
} | ||
|
||
#endif /* LC_KYBER_DEBUG */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* KYBER_DEBUG_H */ |
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.