]> git.cryptolib.org Git - avr-crypto-lib.git/blob - mqq-sign/mqq160-sign_testkey.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / mqq-sign / mqq160-sign_testkey.c
1 /* mqq160-sign_testkey.c */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
5
6     This program is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <stdint.h>
21 #include <avr/pgmspace.h>
22 #include "mqq160-sign.h"
23 #include "mqq160-sign_testkey.h"
24
25 /*
26 This is the private key of MQQ defined by one
27 quadratic quasigroup of order 2^8 given as 81 uint8_ts
28 and one nonsingular matrix SInv given as two arrays
29 RP1[] and RP5[] of 160 uint8_ts.
30 */
31
32
33 const uint8_t a[9*9-1] PROGMEM =
34  { 171, 171, 165,  56, 121, 136,  79, 108,   2,
35    255, 255, 165, 108,  45, 220,  79, 108,  88,
36     54, 108, 103,  21,  74, 119, 141, 204, 221,
37    210, 220,  30, 201, 215, 199,  74,  95, 173,
38    165, 241, 160, 190,  38, 134,  68, 103, 140,
39     84,  84,  68, 157,  81,  65,  30,  11,  48,
40    136, 136,  79,  21, 136, 199,  79,   0, 171,
41    136, 210,  27,  27, 220, 157,  65,  84,  45,
42    225,  61,   8, 232, 235,  49,  22, 146 };
43
44
45 const uint8_t cc1[9] PROGMEM = {  2,  88, 221, 173, 140,  48, 171,  45, 252 };
46 const uint8_t cc2[9] PROGMEM = {225,  61,   8, 232, 235,  49,  22, 146, 252 };
47
48 /* The matrix SInv is stored in ROM as two onedimensional
49 arrays RP1[] and RP5[] of 160 uint8_ts */
50 const uint8_t rp1[160] PROGMEM = {
51         111, 137,  49, 134,   9, 116,  11,  52,  43,  55,
52          74, 130, 119, 144,  31,   7,  72,  79, 105,  59,
53          57, 120,  50,  94, 141, 135, 149,  44, 109, 100,
54         113,   1, 143, 126, 117,  37,  65,  67, 152, 107,
55          10,  98,  15,  23, 138,  19, 121,  18,  28, 156,
56         123, 106,  48,  29,  97,  34,  85, 157,  64,   3,
57          60,  35,  24,  32, 108, 147, 158,  21, 129,  84,
58           5,  70, 118, 112,  30,  68,  47,  40, 150,  13,
59          61,  73, 132,  22,  95, 153,   4,  76,  87, 114,
60         127,  62,  27,  36, 125,  45, 142,  39, 101,  63,
61          88,  96,  12, 115,  82,  91, 159,  93, 155, 154,
62         148, 110,  25,   0,  41,  20,  54,  26,  14,  83,
63          81,  80, 131,  33,  78,  77, 124, 104, 133,  17,
64         145, 139, 122, 102,  42,  56,  75,  66,   2,  16,
65          86, 140,  71, 136,  69,  99,  58,   6,  92,  90,
66           8, 103, 128,  38,  46, 146,  89, 151,  51,  53 };
67
68 const uint8_t rp5[160] PROGMEM = {
69          90, 113, 130, 115, 132,  27,  46,  72,  33,  50,
70          35, 136,  42, 148, 146, 143, 116, 158,  98,  41,
71          39,   5,  54,  86, 106,  56,  30, 138,  80,  44,
72          91,  49,   1, 149, 159, 101,  74,   9, 110, 131,
73          25,  51, 123,  76, 104,  28,  82, 140,   2, 108,
74         120, 144,  10, 145, 124, 119,  62,  57, 117, 121,
75          17,  73, 105,  69, 155,   7, 154,  75, 100, 141,
76         157,  38,  14,  60,  47, 112,  95,  85,  43,  93,
77          24,  12,   4,  71,  81,  13,  94,  68, 107,  67,
78         142, 150,  61,   6, 122,  26, 139,  59, 102, 153,
79         109,  48, 103,  65,  23,  92,  87,  40, 135, 133,
80         129, 134,   8,  55,  83, 125,  31,  96, 147,  36,
81           0, 126,  70,  64,  20,  11, 137,  78,  89,  58,
82          21, 114, 127, 111,  99,  34, 152,  79,  66,  97,
83          22,  15, 151,  32,  84,  37,  77,  88,  16,  29,
84           3, 128, 118,  18, 156,  19,  52,  45,  53,  63 };
85
86 const mqq160_sign_key_t testkey_P PROGMEM = {a, cc1, cc2, rp1, rp5 };
87
88 void mqq_load_pgm_key(void *buffer, mqq160_sign_key_t *key, const mqq160_sign_key_t *key_P){
89         uint8_t *buf_ptr;
90         buf_ptr = buffer;
91         memcpy_P(key, key_P, sizeof(mqq160_sign_key_t));
92
93         memcpy_P(buf_ptr, key->a, MQQ160SIGN_A_SIZE);
94         key->a = buf_ptr;
95         buf_ptr += MQQ160SIGN_A_SIZE;
96
97         memcpy_P(buf_ptr, key->cc1, MQQ160SIGN_CC1_SIZE);
98         key->cc1 = buf_ptr;
99         buf_ptr += MQQ160SIGN_CC1_SIZE;
100
101         memcpy_P(buf_ptr, key->cc2, MQQ160SIGN_CC2_SIZE);
102         key->cc2 = buf_ptr;
103         buf_ptr += MQQ160SIGN_CC2_SIZE;
104
105         memcpy_P(buf_ptr, key->rp1, MQQ160SIGN_RP1_SIZE);
106         key->rp1 = buf_ptr;
107         buf_ptr += MQQ160SIGN_RP1_SIZE;
108
109         memcpy_P(buf_ptr, key->rp5, MQQ160SIGN_RP5_SIZE);
110         key->rp5 = buf_ptr;
111
112 }
113