@@ -13,8 +13,8 @@ Public domain. | |||
#include <openssl/evp.h> | |||
#define SET_KEY_BIT(a,b) (a[15] = (a[15] & 253) | (b << 1)) | |||
#define SET_BLOCK_BIT(a,b) (a[15] = (a[15] & 254) | b) | |||
#define SET_KEY_BIT(a,b) (a[15] = (a[15] & 253) | ((b << 1) & 2)) | |||
#define SET_BLOCK_BIT(a,b) (a[15] = (a[15] & 254) | (b & 1)) | |||
#define WOTS_SELECT_KEY(a) (a[15] = (a[15] & 254) | 1) | |||
#define WOTS_SELECT_BLOCK(a) (a[15] = (a[15] & 254) | 0) | |||
@@ -17,11 +17,11 @@ Public domain. | |||
* in the 16byte hash address | |||
*/ | |||
#define SET_HASH_ADDRESS(a, v) {\ | |||
a[15] = (a[15] & 1) | ((v << 1) & 255);\ | |||
a[15] = (a[15] & 1) | ((v << 1) & 254);\ | |||
a[14] = (a[14] & 254) | ((v >> 7) & 1);} | |||
#define SET_CHAIN_ADDRESS(a, v) {\ | |||
a[14] = (a[14] & 1) | ((v << 1) & 255);\ | |||
a[14] = (a[14] & 1) | ((v << 1) & 254);\ | |||
a[13] = (v >> 7) & 255;\ | |||
a[12] = (a[12] & 254) | ((v >> 15) & 1);} | |||
@@ -24,23 +24,23 @@ Public domain. | |||
* in the 16byte hash address | |||
*/ | |||
#define SET_LAYER_ADDRESS(a, v) {\ | |||
a[6] = (a[6] & 3) | ((v << 2) & 255);\ | |||
a[5] = (a[5] & 252) | ((v >> 6) & 255);} | |||
a[6] = (a[6] & 3) | ((v << 2) & 252);\ | |||
a[5] = (a[5] & 252) | ((v >> 6) & 3);} | |||
#define SET_TREE_ADDRESS(a, v) {\ | |||
a[9] = (a[9] & 3) | ((v << 2) & 255);\ | |||
a[9] = (a[9] & 3) | ((v << 2) & 252);\ | |||
a[8] = (v >> 6) & 255;\ | |||
a[7] = (v >> 14) & 255;\ | |||
a[6] = (a[6] & 252) | ((v >> 22) & 255);} | |||
a[6] = (a[6] & 252) | ((v >> 22) & 3);} | |||
#define SET_OTS_BIT(a, b) {\ | |||
a[9] = (a[9] & 253) | (b << 1);} | |||
a[9] = (a[9] & 253) | ((b << 1) & 2);} | |||
#define SET_OTS_ADDRESS(a, v) {\ | |||
a[12] = (a[12] & 1) | ((v << 1) & 255);\ | |||
a[12] = (a[12] & 1) | ((v << 1) & 254);\ | |||
a[11] = (v >> 7) & 255;\ | |||
a[10] = (v >> 15) & 255;\ | |||
a[9] = (a[9] & 254) | ((v >> 23) & 1);} | |||
a[9] = (a[9] & 254) | ((v >> 23) & 1);} | |||
#define ZEROISE_OTS_ADDR(a) {\ | |||
a[12] = (a[12] & 254);\ | |||
@@ -49,7 +49,7 @@ Public domain. | |||
a[15] = 0;} | |||
#define SET_LTREE_BIT(a, b) {\ | |||
a[9] = (a[9] & 254) | b;} | |||
a[9] = (a[9] & 254) | (b & 1);} | |||
#define SET_LTREE_ADDRESS(a, v) {\ | |||
a[12] = v & 255;\ | |||
@@ -57,10 +57,10 @@ Public domain. | |||
a[10] = (v >> 16) & 255;} | |||
#define SET_LTREE_TREE_HEIGHT(a, v) {\ | |||
a[13] = (a[13] & 3) | ((v << 2) & 255);} | |||
a[13] = (a[13] & 3) | ((v << 2) & 252);} | |||
#define SET_LTREE_TREE_INDEX(a, v) {\ | |||
a[15] = (a[15] & 3) | ((v << 2) & 255);\ | |||
a[15] = (a[15] & 3) | ((v << 2) & 252);\ | |||
a[14] = (v >> 6) & 255;\ | |||
a[13] = (a[13] & 252) | ((v >> 14) & 3);} | |||
@@ -69,11 +69,11 @@ Public domain. | |||
a[11] = a[11] & 3;} | |||
#define SET_NODE_TREE_HEIGHT(a, v) {\ | |||
a[12] = (a[12] & 3) | ((v << 2) & 255);\ | |||
a[12] = (a[12] & 3) | ((v << 2) & 252);\ | |||
a[11] = (a[11] & 252) | ((v >> 6) & 3);} | |||
#define SET_NODE_TREE_INDEX(a, v) {\ | |||
a[15] = (a[15] & 3) | ((v << 2) & 255);\ | |||
a[15] = (a[15] & 3) | ((v << 2) & 252);\ | |||
a[14] = (v >> 6) & 255;\ | |||
a[13] = (v >> 14) & 255;\ | |||
a[12] = (a[12] & 252) | ((v >> 22) & 3);} | |||
@@ -24,23 +24,23 @@ Public domain. | |||
* in the 16byte hash address | |||
*/ | |||
#define SET_LAYER_ADDRESS(a, v) {\ | |||
a[6] = (a[6] & 3) | ((v << 2) & 255);\ | |||
a[5] = (a[5] & 252) | ((v >> 6) & 255);} | |||
a[6] = (a[6] & 3) | ((v << 2) & 252);\ | |||
a[5] = (a[5] & 252) | ((v >> 6) & 3);} | |||
#define SET_TREE_ADDRESS(a, v) {\ | |||
a[9] = (a[9] & 3) | ((v << 2) & 255);\ | |||
a[9] = (a[9] & 3) | ((v << 2) & 252);\ | |||
a[8] = (v >> 6) & 255;\ | |||
a[7] = (v >> 14) & 255;\ | |||
a[6] = (a[6] & 252) | ((v >> 22) & 255);} | |||
a[6] = (a[6] & 252) | ((v >> 22) & 3);} | |||
#define SET_OTS_BIT(a, b) {\ | |||
a[9] = (a[9] & 253) | (b << 1);} | |||
a[9] = (a[9] & 253) | ((b << 1) & 2);} | |||
#define SET_OTS_ADDRESS(a, v) {\ | |||
a[12] = (a[12] & 1) | ((v << 1) & 255);\ | |||
a[12] = (a[12] & 1) | ((v << 1) & 254);\ | |||
a[11] = (v >> 7) & 255;\ | |||
a[10] = (v >> 15) & 255;\ | |||
a[9] = (a[9] & 254) | ((v >> 23) & 1);} | |||
a[9] = (a[9] & 254) | ((v >> 23) & 1);} | |||
#define ZEROISE_OTS_ADDR(a) {\ | |||
a[12] = (a[12] & 254);\ | |||
@@ -49,7 +49,7 @@ Public domain. | |||
a[15] = 0;} | |||
#define SET_LTREE_BIT(a, b) {\ | |||
a[9] = (a[9] & 254) | b;} | |||
a[9] = (a[9] & 254) | (b & 1);} | |||
#define SET_LTREE_ADDRESS(a, v) {\ | |||
a[12] = v & 255;\ | |||
@@ -57,10 +57,10 @@ Public domain. | |||
a[10] = (v >> 16) & 255;} | |||
#define SET_LTREE_TREE_HEIGHT(a, v) {\ | |||
a[13] = (a[13] & 3) | ((v << 2) & 255);} | |||
a[13] = (a[13] & 3) | ((v << 2) & 252);} | |||
#define SET_LTREE_TREE_INDEX(a, v) {\ | |||
a[15] = (a[15] & 3) | ((v << 2) & 255);\ | |||
a[15] = (a[15] & 3) | ((v << 2) & 252);\ | |||
a[14] = (v >> 6) & 255;\ | |||
a[13] = (a[13] & 252) | ((v >> 14) & 3);} | |||
@@ -69,11 +69,11 @@ Public domain. | |||
a[11] = a[11] & 3;} | |||
#define SET_NODE_TREE_HEIGHT(a, v) {\ | |||
a[12] = (a[12] & 3) | ((v << 2) & 255);\ | |||
a[12] = (a[12] & 3) | ((v << 2) & 252);\ | |||
a[11] = (a[11] & 252) | ((v >> 6) & 3);} | |||
#define SET_NODE_TREE_INDEX(a, v) {\ | |||
a[15] = (a[15] & 3) | ((v << 2) & 255);\ | |||
a[15] = (a[15] & 3) | ((v << 2) & 252);\ | |||
a[14] = (v >> 6) & 255;\ | |||
a[13] = (v >> 14) & 255;\ | |||
a[12] = (a[12] & 252) | ((v >> 22) & 3);} | |||