/* mqq160-sign.c */
/*
This file is part of the AVR-Crypto-Lib.
- Copyright (C) 2010 Danilo Gligoroski, Daniel Otte (daniel.otte@rub.de)
+ Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "memxor.h"
#include "mqq160-sign.h"
-static uint8_t mod20_table[32] PROGMEM = {
+static const uint8_t mod20_table[32] PROGMEM = {
4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19,
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
};
-static void memxor_P(void* dest, const void* src, uint16_t length){
- while(length--){
- *((uint8_t*)dest) ^= pgm_read_byte(src);
- dest = (uint8_t*)dest +1;
- src = (uint8_t*)src +1;
- }
-}
-
-static void memxor_idx_P(uint8_t* dest, const uint8_t* src, uint16_t length, uint8_t dist){
+static void memxor_idx_P(uint8_t *dest, const uint8_t *src, uint16_t length, uint8_t dist){
while(length--){
*((uint8_t*)dest) ^= pgm_read_byte((uint8_t*)src);
dest = (uint8_t*)dest + 1;
in the MQQ160-SIGN C Library.
*/
-static void mqq_inv_affine_transformation(uint8_t* input_bytes, uint8_t* result, const mqq160_sign_key_t* key){
+static void mqq_inv_affine_transformation(uint8_t *input_bytes, uint8_t *result, const mqq160_sign_key_t *key){
/* The matrix SInv is given as two permutations of 160 elements. */
uint8_t j, byteindex, bitindex, bitindex_d, byteindex_d, rp1, rp5;
- uint8_t *r1_ptr, *r5_ptr;
+ const uint8_t *r1_ptr, *r5_ptr;
uint8_t h1[20];
/* Initialize H1 and H2 = 0 */
static uint16_t MaskShort[8] = {0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100};
-static uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t* key){
+static uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t *key){
uint8_t e[9];
uint16_t a[8];
uint8_t result, column, row, k;
int8_t j;
uint16_t temp;
- uint8_t *tmp_ptr=key->a;
+ const uint8_t *tmp_ptr=key->a;
if(i&1){
memcpy_P(e, key->cc1, 9);
while(b1){
return(result);
}
-void mqq160_sign_P(void* dest, const void* hash, const mqq160_sign_key_t* key_P){
+void mqq160_sign_P(void *dest, const void *hash, const mqq160_sign_key_t *key_P){
uint8_t i, r1[20], byteindex;
mqq160_sign_key_t key;
memcpy_P(&key, key_P, sizeof(mqq160_sign_key_t));