1 /******************************************************************************
2 * NTRU Cryptography Reference Source Code
3 * Copyright (c) 2009-2013, by Security Innovation, Inc. All rights reserved.
5 * ntru_crypto_msbyte_uint32.h is a component of ntru-crypto.
7 * Copyright (C) 2009-2013 Security Innovation
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 *****************************************************************************/
25 /******************************************************************************
27 * File: ntru_crypto_msbyte_uint32.h
29 * Contents: Definitions and declarations for converting between a most-
30 * significant-first byte stream and a uint32_t array.
32 *****************************************************************************/
34 #ifndef NTRU_CRYPTO_MSBYTE_UINT32_H
35 #define NTRU_CRYPTO_MSBYTE_UINT32_H
38 #include "ntru_crypto_platform.h"
41 /* ntru_crypto_msbyte_2_uint32()
43 * This routine converts an array of bytes in network byte order to an array
44 * of uint32_t, placing the first byte in the most significant byte of the
45 * first uint32_t word.
47 * The number of bytes in the input stream MUST be at least 4 times the
48 * number of words expected in the output array.
52 ntru_crypto_msbyte_2_uint32(
53 uint32_t *words
, // out - pointer to the output uint32_t array
54 uint8_t const *bytes
, // in - pointer to the input byte array
55 uint32_t n
); // in - number of words in the output array
58 /* ntru_crypto_uint32_2_msbyte()
60 * This routine converts an array of uint32_t to an array of bytes in
61 * network byte order, placing the most significant byte of the first uint32_t
62 * word as the first byte of the output array.
64 * The number of bytes in the output stream will be 4 times the number of words
65 * specified in the input array.
69 ntru_crypto_uint32_2_msbyte(
70 uint8_t *bytes
, // out - pointer to the output byte array
71 uint32_t const *words
, // in - pointer to the input uint32_t array
72 uint32_t n
); // in - number of words in the input array
75 #endif /* NTRU_CRYPTO_MSBYTE_UINT32_H */