291
|
1 |
/*
|
|
2 |
* Portions Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* The original NIST Statistical Test Suite code is placed in public domain.
|
|
16 |
* (http://csrc.nist.gov/groups/ST/toolkit/rng/documentation_software.html)
|
|
17 |
*
|
|
18 |
* This software was developed at the National Institute of Standards and Technology by
|
|
19 |
* employees of the Federal Government in the course of their official duties. Pursuant
|
|
20 |
* to title 17 Section 105 of the United States Code this software is not subject to
|
|
21 |
* copyright protection and is in the public domain. The NIST Statistical Test Suite is
|
|
22 |
* an experimental system. NIST assumes no responsibility whatsoever for its use by other
|
|
23 |
* parties, and makes no guarantees, expressed or implied, about its quality, reliability,
|
|
24 |
* or any other characteristic. We would appreciate acknowledgment if the software is used.
|
|
25 |
*/
|
|
26 |
|
|
27 |
#ifndef _GENUTILS_H_
|
|
28 |
#define _GENUTILS_H_
|
|
29 |
|
|
30 |
#include "openc.h"
|
|
31 |
#include "config.h"
|
|
32 |
|
|
33 |
typedef struct _MP_struct {
|
|
34 |
int size; /* in bytes */
|
|
35 |
int bitlen; /* in bits, duh */
|
|
36 |
BYTE *val;
|
|
37 |
} MP;
|
|
38 |
|
|
39 |
#define FREE(A) if ( (A) ) { free((A)); (A) = NULL; }
|
|
40 |
#define ASCII2BIN(ch) ( (((ch) >= '0') && ((ch) <= '9')) ? ((ch) - '0') : (((ch) >= 'A') && ((ch) <= 'F')) ? ((ch) - 'A' + 10) : ((ch) - 'a' + 10) )
|
|
41 |
|
|
42 |
#ifndef EXPWD
|
|
43 |
#define EXPWD ((DBLWORD)1<<NUMLEN)
|
|
44 |
#endif
|
|
45 |
|
|
46 |
#define sniff_bit(ptr,mask) (*(ptr) & mask)
|
|
47 |
|
|
48 |
/*
|
|
49 |
* Function Declarations
|
|
50 |
*/
|
|
51 |
int greater(BYTE *x, BYTE *y, int l);
|
|
52 |
int less(BYTE *x, BYTE *y, int l);
|
|
53 |
BYTE bshl(BYTE *x, int l);
|
|
54 |
void bshr(BYTE *x, int l);
|
|
55 |
int Mult(BYTE *A, BYTE *B, int LB, BYTE *C, int LC);
|
|
56 |
void ModSqr(BYTE *A, BYTE *B, int LB, BYTE *M, int LM);
|
|
57 |
void ModMult(BYTE *A, BYTE *B, int LB, BYTE *C, int LC, BYTE *M, int LM);
|
|
58 |
void smult(BYTE *A, BYTE b, BYTE *C, int L);
|
|
59 |
void Square(BYTE *A, BYTE *B, int L);
|
|
60 |
void ModExp(BYTE *A, BYTE *B, int LB, BYTE *C, int LC, BYTE *M, int LM);
|
|
61 |
int DivMod(BYTE *x, int lenx, BYTE *n, int lenn, BYTE *quot, BYTE *rem);
|
|
62 |
void Mod(BYTE *x, int lenx, BYTE *n, int lenn);
|
|
63 |
void Div(BYTE *x, int lenx, BYTE *n, int lenn);
|
|
64 |
void sub(BYTE *A, int LA, BYTE *B, int LB);
|
|
65 |
int negate(BYTE *A, int L);
|
|
66 |
BYTE add(BYTE *A, int LA, BYTE *B, int LB);
|
|
67 |
void prettyprintBstr(char *S, BYTE *A, int L);
|
|
68 |
void byteReverse(ULONG *buffer, int byteCount);
|
|
69 |
void ahtopb (char *ascii_hex, BYTE *p_binary, int bin_len);
|
|
70 |
|
|
71 |
#endif /* _GENUTILS_H_ */
|