Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
3ec9dceb
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
10
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3ec9dceb
编写于
11月 02, 2011
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add fips_algvs utility (from FIPS 2.0 stable branch).
上级
92064785
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
446 addition
and
55 deletion
+446
-55
CHANGES
CHANGES
+4
-0
Makefile.fips
Makefile.fips
+2
-0
fips/aes/fips_aesavs.c
fips/aes/fips_aesavs.c
+6
-3
fips/aes/fips_gcmtest.c
fips/aes/fips_gcmtest.c
+5
-1
fips/cmac/fips_cmactest.c
fips/cmac/fips_cmactest.c
+4
-0
fips/des/fips_desmovs.c
fips/des/fips_desmovs.c
+29
-23
fips/dh/fips_dhvs.c
fips/dh/fips_dhvs.c
+6
-2
fips/dsa/fips_dssvs.c
fips/dsa/fips_dssvs.c
+5
-1
fips/ecdh/fips_ecdhvs.c
fips/ecdh/fips_ecdhvs.c
+7
-3
fips/ecdsa/fips_ecdsavs.c
fips/ecdsa/fips_ecdsavs.c
+9
-6
fips/fips_test_suite.c
fips/fips_test_suite.c
+9
-5
fips/fips_utl.h
fips/fips_utl.h
+5
-0
fips/hmac/fips_hmactest.c
fips/hmac/fips_hmactest.c
+4
-0
fips/rand/fips_drbgvs.c
fips/rand/fips_drbgvs.c
+7
-5
fips/rand/fips_rngvs.c
fips/rand/fips_rngvs.c
+5
-1
fips/rsa/fips_rsagtest.c
fips/rsa/fips_rsagtest.c
+4
-0
fips/rsa/fips_rsastest.c
fips/rsa/fips_rsastest.c
+4
-0
fips/rsa/fips_rsavtest.c
fips/rsa/fips_rsavtest.c
+7
-3
fips/sha/fips_shatest.c
fips/sha/fips_shatest.c
+4
-0
test/Makefile
test/Makefile
+8
-2
test/fips_algvs.c
test/fips_algvs.c
+312
-0
未找到文件。
CHANGES
浏览文件 @
3ec9dceb
...
...
@@ -4,6 +4,10 @@
Changes between 1.0.1 and 1.1.0 [xx XXX xxxx]
*) Add fips_algvs: a multicall fips utility incorporaing all the algorithm
test programs and fips_test_suite. Includes functionality to parse
the minimal script output of fipsalgest.pl directly.
*) Add authorisation parameter to FIPS_module_mode_set().
[Steve Henson]
...
...
Makefile.fips
浏览文件 @
3ec9dceb
...
...
@@ -387,6 +387,8 @@ build_apps:
@
dir
=
apps
;
target
=
all
;
$(BUILD_ONE_CMD)
build_tests
:
@
dir
=
test
;
target
=
fipsexe
;
$(BUILD_ONE_CMD)
build_algvs
:
@
dir
=
test
;
target
=
fipsalgvs
;
$(BUILD_ONE_CMD)
build_tools
:
@
dir
=
tools
;
target
=
all
;
$(BUILD_ONE_CMD)
...
...
fips/aes/fips_aesavs.c
浏览文件 @
3ec9dceb
...
...
@@ -780,7 +780,7 @@ static int proc_file(char *rqfile, char *rspfile)
if
(
do_mct
(
amode
,
akeysz
,
aKey
,
iVec
,
dir
,
(
unsigned
char
*
)
plaintext
,
len
,
rfp
)
<
0
)
EXIT
(
1
)
;
err
=
1
;
}
else
{
...
...
@@ -862,7 +862,11 @@ static int proc_file(char *rqfile, char *rspfile)
aes_test -d xxxxx.xxx
The default is: -d req.txt
--------------------------------------------------*/
#ifdef FIPS_ALGVS
int
fips_aesavs_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
char
*
rqlist
=
"req.txt"
,
*
rspfile
=
NULL
;
FILE
*
fp
=
NULL
;
...
...
@@ -915,7 +919,7 @@ int main(int argc, char **argv)
if
(
proc_file
(
rfn
,
rspfile
))
{
printf
(
">>> Processing failed for: %s <<<
\n
"
,
rfn
);
EXIT
(
1
)
;
return
1
;
}
}
fclose
(
fp
);
...
...
@@ -929,7 +933,6 @@ int main(int argc, char **argv)
printf
(
">>> Processing failed for: %s <<<
\n
"
,
fn
);
}
}
EXIT
(
0
);
return
0
;
}
...
...
fips/aes/fips_gcmtest.c
浏览文件 @
3ec9dceb
...
...
@@ -496,7 +496,11 @@ static void ccmtest(FILE *in, FILE *out)
FIPS_cipher_ctx_cleanup
(
&
ctx
);
}
int
main
(
int
argc
,
char
**
argv
)
#ifdef FIPS_ALGVS
int
fips_gcmtest_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
int
encrypt
;
int
xts
=
0
,
ccm
=
0
;
...
...
fips/cmac/fips_cmactest.c
浏览文件 @
3ec9dceb
...
...
@@ -92,7 +92,11 @@ static int print_cmac_ver(const EVP_CIPHER *cipher, FILE *out,
unsigned
char
*
Mac
,
int
Maclen
,
int
Tlen
);
#ifdef FIPS_ALGVS
int
fips_cmactest_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
=
NULL
,
*
out
=
NULL
;
int
mode
=
0
;
/* 0 => Generate, 1 => Verify */
...
...
fips/des/fips_desmovs.c
浏览文件 @
3ec9dceb
...
...
@@ -102,7 +102,7 @@ static int DESTest(EVP_CIPHER_CTX *ctx,
if
(
akeysz
!=
192
)
{
printf
(
"Invalid key size: %d
\n
"
,
akeysz
);
EXIT
(
1
)
;
return
0
;
}
if
(
fips_strcasecmp
(
amode
,
"CBC"
)
==
0
)
...
...
@@ -120,7 +120,7 @@ static int DESTest(EVP_CIPHER_CTX *ctx,
else
{
printf
(
"Unknown mode: %s
\n
"
,
amode
);
EXIT
(
1
)
;
return
0
;
}
if
(
FIPS_cipherinit
(
ctx
,
cipher
,
aKey
,
iVec
,
dir
)
<=
0
)
...
...
@@ -155,12 +155,12 @@ static void shiftin(unsigned char *dst,unsigned char *src,int nbits)
}
/*-----------------------------------------------*/
char
*
t_tag
[
2
]
=
{
"PLAINTEXT"
,
"CIPHERTEXT"
};
char
*
t_mode
[
6
]
=
{
"CBC"
,
"ECB"
,
"OFB"
,
"CFB1"
,
"CFB8"
,
"CFB64"
};
enum
Mode
{
CBC
,
ECB
,
OFB
,
CFB1
,
CFB8
,
CFB64
};
char
*
t
des_t
_tag
[
2
]
=
{
"PLAINTEXT"
,
"CIPHERTEXT"
};
char
*
t
des_t
_mode
[
6
]
=
{
"CBC"
,
"ECB"
,
"OFB"
,
"CFB1"
,
"CFB8"
,
"CFB64"
};
enum
tdes_Mode
{
TCBC
,
TECB
,
TOFB
,
TCFB1
,
TCFB8
,
T
CFB64
};
int
Sizes
[
6
]
=
{
64
,
64
,
64
,
1
,
8
,
64
};
static
void
do_
mct
(
char
*
amode
,
static
int
do_t
mct
(
char
*
amode
,
int
akeysz
,
int
numkeys
,
unsigned
char
*
akey
,
unsigned
char
*
ivec
,
int
dir
,
unsigned
char
*
text
,
int
len
,
FILE
*
rfp
)
...
...
@@ -170,12 +170,12 @@ static void do_mct(char *amode,
unsigned
char
text0
[
8
];
for
(
imode
=
0
;
imode
<
6
;
++
imode
)
if
(
!
strcmp
(
amode
,
t_mode
[
imode
]))
if
(
!
strcmp
(
amode
,
t
des_t
_mode
[
imode
]))
break
;
if
(
imode
==
6
)
{
printf
(
"Unrecognized mode: %s
\n
"
,
amode
);
EXIT
(
1
)
;
return
0
;
}
for
(
i
=
0
;
i
<
400
;
++
i
)
{
...
...
@@ -196,12 +196,12 @@ static void do_mct(char *amode,
OutputValue
(
""
,
akey
+
n
*
8
,
8
,
rfp
,
0
);
}
if
(
imode
!=
ECB
)
if
(
imode
!=
T
ECB
)
OutputValue
(
"IV"
,
ivec
,
8
,
rfp
,
0
);
OutputValue
(
t
_tag
[
dir
^
1
],
text
,
len
,
rfp
,
imode
==
CFB1
);
OutputValue
(
t
des_t_tag
[
dir
^
1
],
text
,
len
,
rfp
,
imode
==
T
CFB1
);
#if 0
/* compensate for endianness */
if(imode == CFB1)
if(imode ==
T
CFB1)
text[0]<<=7;
#endif
memcpy
(
text0
,
text
,
8
);
...
...
@@ -223,18 +223,18 @@ static void do_mct(char *amode,
}
if
(
j
==
9999
)
{
OutputValue
(
t
_tag
[
dir
],
text
,
len
,
rfp
,
imode
==
CFB1
);
OutputValue
(
t
des_t_tag
[
dir
],
text
,
len
,
rfp
,
imode
==
T
CFB1
);
/* memcpy(ivec,text,8); */
}
/* DebugValue("iv",ctx.iv,8); */
/* accumulate material for the next key */
shiftin
(
nk
,
text
,
Sizes
[
imode
]);
/* DebugValue("nk",nk,24);*/
if
((
dir
&&
(
imode
==
CFB1
||
imode
==
CFB8
||
imode
==
CFB64
||
imode
==
CBC
))
||
imode
==
OFB
)
if
((
dir
&&
(
imode
==
TCFB1
||
imode
==
TCFB8
||
imode
==
TCFB64
||
imode
==
TCBC
))
||
imode
==
T
OFB
)
memcpy
(
text
,
old_iv
,
8
);
if
(
!
dir
&&
(
imode
==
CFB1
||
imode
==
CFB8
||
imode
==
CFB64
))
if
(
!
dir
&&
(
imode
==
TCFB1
||
imode
==
TCFB8
||
imode
==
T
CFB64
))
{
/* the test specifies using the output of the raw DES operation
which we don't have, so reconstruct it... */
...
...
@@ -260,13 +260,14 @@ static void do_mct(char *amode,
/* pointless exercise - the final text doesn't depend on the
initial text in OFB mode, so who cares what it is? (Who
designed these tests?) */
if
(
imode
==
OFB
)
if
(
imode
==
T
OFB
)
for
(
n
=
0
;
n
<
8
;
++
n
)
text
[
n
]
=
text0
[
n
]
^
old_iv
[
n
];
}
return
1
;
}
static
int
proc_file
(
char
*
rqfile
,
char
*
rspfile
)
static
int
t
proc_file
(
char
*
rqfile
,
char
*
rspfile
)
{
char
afn
[
256
],
rfn
[
256
];
FILE
*
afp
=
NULL
,
*
rfp
=
NULL
;
...
...
@@ -546,7 +547,9 @@ static int proc_file(char *rqfile, char *rspfile)
PrintValue
(
"PLAINTEXT"
,
(
unsigned
char
*
)
plaintext
,
len
);
if
(
strcmp
(
atest
,
"Monte"
)
==
0
)
/* Monte Carlo Test */
{
do_mct
(
amode
,
akeysz
,
numkeys
,
aKey
,
iVec
,
dir
,
plaintext
,
len
,
rfp
);
if
(
!
do_tmct
(
amode
,
akeysz
,
numkeys
,
aKey
,
iVec
,
dir
,
plaintext
,
len
,
rfp
))
return
-
1
;
}
else
{
...
...
@@ -585,7 +588,7 @@ static int proc_file(char *rqfile, char *rspfile)
PrintValue
(
"CIPHERTEXT"
,
ciphertext
,
len
);
if
(
strcmp
(
atest
,
"Monte"
)
==
0
)
/* Monte Carlo Test */
{
do_mct
(
amode
,
akeysz
,
numkeys
,
aKey
,
iVec
,
do_
t
mct
(
amode
,
akeysz
,
numkeys
,
aKey
,
iVec
,
dir
,
ciphertext
,
len
,
rfp
);
}
else
...
...
@@ -631,7 +634,11 @@ static int proc_file(char *rqfile, char *rspfile)
aes_test -d xxxxx.xxx
The default is: -d req.txt
--------------------------------------------------*/
#ifdef FIPS_ALGVS
int
fips_desmovs_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
char
*
rqlist
=
"req.txt"
,
*
rspfile
=
NULL
;
FILE
*
fp
=
NULL
;
...
...
@@ -680,10 +687,10 @@ int main(int argc, char **argv)
strtok
(
fn
,
"
\r\n
"
);
strcpy
(
rfn
,
fn
);
printf
(
"Processing: %s
\n
"
,
rfn
);
if
(
proc_file
(
rfn
,
rspfile
))
if
(
t
proc_file
(
rfn
,
rspfile
))
{
printf
(
">>> Processing failed for: %s <<<
\n
"
,
rfn
);
EXIT
(
1
)
;
return
-
1
;
}
}
fclose
(
fp
);
...
...
@@ -692,12 +699,11 @@ int main(int argc, char **argv)
{
if
(
VERBOSE
)
printf
(
"Processing: %s
\n
"
,
fn
);
if
(
proc_file
(
fn
,
rspfile
))
if
(
t
proc_file
(
fn
,
rspfile
))
{
printf
(
">>> Processing failed for: %s <<<
\n
"
,
fn
);
}
}
EXIT
(
0
);
return
0
;
}
...
...
fips/dh/fips_dhvs.c
浏览文件 @
3ec9dceb
...
...
@@ -145,8 +145,12 @@ static void output_Zhash(FILE *out, int exout,
OPENSSL_cleanse
(
Z
,
Zlen
);
OPENSSL_free
(
Z
);
}
int
main
(
int
argc
,
char
**
argv
)
#ifdef FIPS_ALGVS
int
fips_dhvs_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
char
**
args
=
argv
+
1
;
int
argn
=
argc
-
1
;
...
...
fips/dsa/fips_dssvs.c
浏览文件 @
3ec9dceb
...
...
@@ -717,7 +717,11 @@ static void sigver(FILE *in, FILE *out)
}
}
int
main
(
int
argc
,
char
**
argv
)
#ifdef FIPS_ALGVS
int
fips_dssvs_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
,
*
out
;
if
(
argc
==
4
)
...
...
fips/ecdh/fips_ecdhvs.c
浏览文件 @
3ec9dceb
...
...
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
#include "fips_utl.h"
static
const
EVP_MD
*
parse_md
(
char
*
line
)
static
const
EVP_MD
*
e
parse_md
(
char
*
line
)
{
char
*
p
;
if
(
line
[
0
]
!=
'['
||
line
[
1
]
!=
'E'
)
...
...
@@ -301,7 +301,11 @@ static void ec_output_Zhash(FILE *out, int exout, EC_GROUP *group,
EC_POINT_free
(
peerkey
);
}
int
main
(
int
argc
,
char
**
argv
)
#ifdef FIPS_ALGVS
int
fips_ecdhvs_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
char
**
args
=
argv
+
1
;
int
argn
=
argc
-
1
;
...
...
@@ -412,7 +416,7 @@ int main(int argc,char **argv)
if
(
strlen
(
buf
)
>
6
&&
!
strncmp
(
buf
,
"[E"
,
2
))
{
md
=
parse_md
(
buf
);
md
=
e
parse_md
(
buf
);
if
(
md
==
NULL
)
goto
parse_error
;
continue
;
...
...
fips/ecdsa/fips_ecdsavs.c
浏览文件 @
3ec9dceb
...
...
@@ -75,7 +75,7 @@ int main(int argc, char **argv)
#include <openssl/objects.h>
static
int
lookup_curve
(
char
*
in
,
char
*
curve_name
,
const
EVP_MD
**
pmd
)
static
int
e
lookup_curve
(
char
*
in
,
char
*
curve_name
,
const
EVP_MD
**
pmd
)
{
char
*
cname
,
*
p
;
/* Copy buffer as we will change it */
...
...
@@ -200,7 +200,7 @@ static int KeyPair(FILE *in, FILE *out)
if
(
*
buf
==
'['
&&
buf
[
2
]
==
'-'
)
{
if
(
buf
[
2
]
==
'-'
)
curve_nid
=
lookup_curve
(
buf
,
lbuf
,
NULL
);
curve_nid
=
e
lookup_curve
(
buf
,
lbuf
,
NULL
);
fputs
(
buf
,
out
);
continue
;
}
...
...
@@ -260,7 +260,7 @@ static int PKV(FILE *in, FILE *out)
fputs
(
buf
,
out
);
if
(
*
buf
==
'['
&&
buf
[
2
]
==
'-'
)
{
curve_nid
=
lookup_curve
(
buf
,
lbuf
,
NULL
);
curve_nid
=
e
lookup_curve
(
buf
,
lbuf
,
NULL
);
if
(
curve_nid
==
NID_undef
)
return
0
;
...
...
@@ -314,7 +314,7 @@ static int SigGen(FILE *in, FILE *out)
fputs
(
buf
,
out
);
if
(
*
buf
==
'['
)
{
curve_nid
=
lookup_curve
(
buf
,
lbuf
,
&
digest
);
curve_nid
=
e
lookup_curve
(
buf
,
lbuf
,
&
digest
);
if
(
curve_nid
==
NID_undef
)
return
0
;
}
...
...
@@ -390,7 +390,7 @@ static int SigVer(FILE *in, FILE *out)
fputs
(
buf
,
out
);
if
(
*
buf
==
'['
)
{
curve_nid
=
lookup_curve
(
buf
,
lbuf
,
&
digest
);
curve_nid
=
e
lookup_curve
(
buf
,
lbuf
,
&
digest
);
if
(
curve_nid
==
NID_undef
)
return
0
;
}
...
...
@@ -459,8 +459,11 @@ static int SigVer(FILE *in, FILE *out)
}
return
1
;
}
#ifdef FIPS_ALGVS
int
fips_ecdsavs_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
=
NULL
,
*
out
=
NULL
;
const
char
*
cmd
=
argv
[
1
];
...
...
fips/fips_test_suite.c
浏览文件 @
3ec9dceb
...
...
@@ -995,7 +995,11 @@ static int post_cb(int op, int id, int subid, void *ex)
return
1
;
}
int
main
(
int
argc
,
char
**
argv
)
#ifdef FIPS_ALGVS
int
fips_test_suite_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
int
bad_rsa
=
0
,
bad_dsa
=
0
;
int
do_rng_stick
=
0
;
...
...
@@ -1088,16 +1092,16 @@ int main(int argc,char **argv)
pass
=
""
;
}
else
{
printf
(
"Bad argument
\"
%s
\"\n
"
,
argv
[
1
]);
exit
(
1
)
;
return
1
;
}
if
(
!
no_exit
)
{
fips_algtest_init_nofips
();
if
(
!
FIPS_module_mode_set
(
1
,
pass
))
{
printf
(
"Power-up self test failed
\n
"
);
exit
(
1
)
;
return
1
;
}
printf
(
"Power-up self test successful
\n
"
);
exit
(
0
)
;
return
0
;
}
}
...
...
@@ -1116,7 +1120,7 @@ int main(int argc,char **argv)
ERR_clear_error
();
test_msg
(
"2. Automatic power-up self test"
,
FIPS_module_mode_set
(
1
,
pass
));
if
(
!
FIPS_module_mode
())
exit
(
1
)
;
return
1
;
if
(
do_drbg_stick
)
FIPS_drbg_stick
();
if
(
do_rng_stick
)
...
...
fips/fips_utl.h
浏览文件 @
3ec9dceb
...
...
@@ -47,6 +47,9 @@
*
*/
#ifndef FIPS_UTL_H
#define FIPS_UTL_H
#define OPENSSL_FIPSAPI
#include <openssl/fips_rand.h>
...
...
@@ -487,3 +490,5 @@ int fips_strcasecmp(const char *str1, const char *str2)
return
fips_strncasecmp
(
str1
,
str2
,
(
size_t
)
-
1
);
}
#endif
fips/hmac/fips_hmactest.c
浏览文件 @
3ec9dceb
...
...
@@ -85,7 +85,11 @@ static int print_hmac(const EVP_MD *md, FILE *out,
unsigned
char
*
Key
,
int
Klen
,
unsigned
char
*
Msg
,
int
Msglen
,
int
Tlen
);
#ifdef FIPS_ALGVS
int
fips_hmactest_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
=
NULL
,
*
out
=
NULL
;
...
...
fips/rand/fips_drbgvs.c
浏览文件 @
3ec9dceb
...
...
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
#include "fips_utl.h"
static
int
parse_md
(
char
*
str
)
static
int
d
parse_md
(
char
*
str
)
{
switch
(
atoi
(
str
+
5
))
{
...
...
@@ -115,7 +115,7 @@ static int parse_ec(char *str)
curve_nid
=
NID_secp521r1
;
else
return
NID_undef
;
md_nid
=
parse_md
(
md
);
md_nid
=
d
parse_md
(
md
);
if
(
md_nid
==
NID_undef
)
return
NID_undef
;
return
(
curve_nid
<<
16
)
|
md_nid
;
...
...
@@ -170,9 +170,11 @@ static size_t test_nonce(DRBG_CTX *dctx, unsigned char **pout,
return
t
->
noncelen
;
}
#ifdef FIPS_ALGVS
int
fips_drbgvs_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
,
*
out
;
DRBG_CTX
*
dctx
=
NULL
;
...
...
@@ -240,7 +242,7 @@ int main(int argc,char **argv)
}
if
(
strlen
(
buf
)
>
4
&&
!
strncmp
(
buf
,
"[SHA-"
,
5
))
{
nid
=
parse_md
(
buf
);
nid
=
d
parse_md
(
buf
);
if
(
nid
==
NID_undef
)
exit
(
1
);
if
(
drbg_type
==
DRBG_HMAC
)
...
...
fips/rand/fips_rngvs.c
浏览文件 @
3ec9dceb
...
...
@@ -198,7 +198,11 @@ static void mct(FILE *in, FILE *out)
}
}
int
main
(
int
argc
,
char
**
argv
)
#ifdef FIPS_ALGVS
int
fips_rngvs_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
,
*
out
;
if
(
argc
==
4
)
...
...
fips/rsa/fips_rsagtest.c
浏览文件 @
3ec9dceb
...
...
@@ -88,7 +88,11 @@ static int rsa_printkey1(FILE *out, RSA *rsa,
static
int
rsa_printkey2
(
FILE
*
out
,
RSA
*
rsa
,
BIGNUM
*
Xq1
,
BIGNUM
*
Xq2
,
BIGNUM
*
Xq
);
#ifdef FIPS_ALGVS
int
fips_rsagtest_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
=
NULL
,
*
out
=
NULL
;
...
...
fips/rsa/fips_rsastest.c
浏览文件 @
3ec9dceb
...
...
@@ -85,7 +85,11 @@ static int rsa_stest(FILE *out, FILE *in, int Saltlen);
static
int
rsa_printsig
(
FILE
*
out
,
RSA
*
rsa
,
const
EVP_MD
*
dgst
,
unsigned
char
*
Msg
,
long
Msglen
,
int
Saltlen
);
#ifdef FIPS_ALGVS
int
fips_rsastest_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
=
NULL
,
*
out
=
NULL
;
...
...
fips/rsa/fips_rsavtest.c
浏览文件 @
3ec9dceb
...
...
@@ -82,14 +82,18 @@ int main(int argc, char *argv[])
#include "fips_utl.h"
int
rsa_test
(
FILE
*
out
,
FILE
*
in
,
int
saltlen
);
int
rsa_
v
test
(
FILE
*
out
,
FILE
*
in
,
int
saltlen
);
static
int
rsa_printver
(
FILE
*
out
,
BIGNUM
*
n
,
BIGNUM
*
e
,
const
EVP_MD
*
dgst
,
unsigned
char
*
Msg
,
long
Msglen
,
unsigned
char
*
S
,
long
Slen
,
int
Saltlen
);
#ifdef FIPS_ALGVS
int
fips_rsavtest_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
=
NULL
,
*
out
=
NULL
;
...
...
@@ -138,7 +142,7 @@ int main(int argc, char **argv)
goto
end
;
}
if
(
!
rsa_test
(
out
,
in
,
Saltlen
))
if
(
!
rsa_
v
test
(
out
,
in
,
Saltlen
))
{
fprintf
(
stderr
,
"FATAL RSAVTEST file processing error
\n
"
);
goto
end
;
...
...
@@ -159,7 +163,7 @@ int main(int argc, char **argv)
#define RSA_TEST_MAXLINELEN 10240
int
rsa_test
(
FILE
*
out
,
FILE
*
in
,
int
Saltlen
)
int
rsa_
v
test
(
FILE
*
out
,
FILE
*
in
,
int
Saltlen
)
{
char
*
linebuf
,
*
olinebuf
,
*
p
,
*
q
;
char
*
keyword
,
*
value
;
...
...
fips/sha/fips_shatest.c
浏览文件 @
3ec9dceb
...
...
@@ -86,7 +86,11 @@ static int print_dgst(const EVP_MD *md, FILE *out,
static
int
print_monte
(
const
EVP_MD
*
md
,
FILE
*
out
,
unsigned
char
*
Seed
,
int
SeedLen
);
#ifdef FIPS_ALGVS
int
fips_shatest_main
(
int
argc
,
char
**
argv
)
#else
int
main
(
int
argc
,
char
**
argv
)
#endif
{
FILE
*
in
=
NULL
,
*
out
=
NULL
;
...
...
test/Makefile
浏览文件 @
3ec9dceb
...
...
@@ -81,6 +81,7 @@ FIPS_ECDHVS= fips_ecdhvs
FIPS_ECDSAVS
=
fips_ecdsavs
FIPS_TEST_SUITE
=
fips_test_suite
FIPS_CMACTEST
=
fips_cmactest
FIPS_ALGVS
=
fips_algvs
TESTS
=
alltests
...
...
@@ -119,7 +120,7 @@ OBJ= $(BNTEST).o $(ECTEST).o $(ECDSATEST).o $(ECDHTEST).o $(IDEATEST).o \
$(FIPS_RSASTEST)
.o
$(FIPS_RSAGTEST)
.o
$(FIPS_GCMTEST)
.o
\
$(FIPS_DSSVS)
.o
$(FIPS_DSATEST)
.o
$(FIPS_RNGVS)
.o
$(FIPS_DRBGVS)
.o
\
$(FIPS_TEST_SUITE)
.o
$(FIPS_DHVS)
.o
$(FIPS_ECDSAVS)
.o
\
$(FIPS_ECDHVS)
.o
$(FIPS_CMACTEST)
.o
\
$(FIPS_ECDHVS)
.o
$(FIPS_CMACTEST)
.o
$(FIPS_ALGVS)
.o
\
$(EVPTEST)
.o
$(IGETEST)
.o
$(JPAKETEST)
.o
SRC
=
$(BNTEST)
.c
$(ECTEST)
.c
$(ECDSATEST)
.c
$(ECDHTEST)
.c
$(IDEATEST)
.c
\
$(MD2TEST)
.c
$(MD4TEST)
.c
$(MD5TEST)
.c
\
...
...
@@ -133,7 +134,7 @@ SRC= $(BNTEST).c $(ECTEST).c $(ECDSATEST).c $(ECDHTEST).c $(IDEATEST).c \
$(FIPS_RSASTEST)
.c
$(FIPS_RSAGTEST)
.c
$(FIPS_GCMTEST)
.c
\
$(FIPS_DSSVS)
.c
$(FIPS_DSATEST)
.c
$(FIPS_RNGVS)
.c
$(FIPS_DRBGVS)
.c
\
$(FIPS_TEST_SUITE)
.c
$(FIPS_DHVS)
.c
$(FIPS_ECDSAVS)
.c
\
$(FIPS_ECDHVS)
.c
$(FIPS_CMACTEST)
.c
\
$(FIPS_ECDHVS)
.c
$(FIPS_CMACTEST)
.c
$(FIPS_ALGVS)
.c
\
$(EVPTEST)
.c
$(IGETEST)
.c
$(JPAKETEST)
.c
EXHEADER
=
...
...
@@ -150,6 +151,8 @@ exe: $(EXE) $(FIPSEXE) dummytest$(EXE_EXT)
fipsexe
:
$(FIPSEXE)
fipsalgvs
:
$(FIPS_ALGVS)
files
:
$(PERL)
$(TOP)
/util/files.pl Makefile
>>
$(TOP)
/MINFO
...
...
@@ -504,6 +507,9 @@ $(FIPS_TEST_SUITE)$(EXE_EXT): $(FIPS_TEST_SUITE).o $(DLIBCRYPTO)
$(FIPS_CMACTEST)$(EXE_EXT)
:
$(FIPS_CMACTEST).o $(DLIBCRYPTO)
@
target
=
$(FIPS_CMACTEST)
;
$(FIPS_BUILD_CMD)
$(FIPS_ALGVS)$(EXE_EXT)
:
$(FIPS_ALGVS).o $(DLIBCRYPTO)
@
target
=
$(FIPS_ALGVS)
;
$(FIPS_BUILD_CMD)
$(RMDTEST)$(EXE_EXT)
:
$(RMDTEST).o $(DLIBCRYPTO)
@
target
=
$(RMDTEST)
;
$(BUILD_CMD)
...
...
test/fips_algvs.c
0 → 100644
浏览文件 @
3ec9dceb
/* test/fips_algvs.c */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2011
*/
/* ====================================================================
* Copyright (c) 2011 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* licensing@OpenSSL.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
#include <stdio.h>
#include <openssl/crypto.h>
#include <openssl/opensslconf.h>
#ifndef OPENSSL_FIPS
#include <stdio.h>
int
main
(
int
argc
,
char
**
argv
)
{
printf
(
"No FIPS ALGVS support
\n
"
);
return
0
;
}
#else
#define FIPS_ALGVS
extern
int
fips_aesavs_main
(
int
argc
,
char
**
argv
);
extern
int
fips_cmactest_main
(
int
argc
,
char
**
argv
);
extern
int
fips_desmovs_main
(
int
argc
,
char
**
argv
);
extern
int
fips_dhvs_main
(
int
argc
,
char
**
argv
);
extern
int
fips_drbgvs_main
(
int
argc
,
char
**
argv
);
extern
int
fips_dssvs_main
(
int
argc
,
char
**
argv
);
extern
int
fips_ecdhvs_main
(
int
argc
,
char
**
argv
);
extern
int
fips_ecdsavs_main
(
int
argc
,
char
**
argv
);
extern
int
fips_gcmtest_main
(
int
argc
,
char
**
argv
);
extern
int
fips_hmactest_main
(
int
argc
,
char
**
argv
);
extern
int
fips_rngvs_main
(
int
argc
,
char
**
argv
);
extern
int
fips_rsagtest_main
(
int
argc
,
char
**
argv
);
extern
int
fips_rsastest_main
(
int
argc
,
char
**
argv
);
extern
int
fips_rsavtest_main
(
int
argc
,
char
**
argv
);
extern
int
fips_shatest_main
(
int
argc
,
char
**
argv
);
extern
int
fips_test_suite_main
(
int
argc
,
char
**
argv
);
#include "fips_aesavs.c"
#include "fips_cmactest.c"
#include "fips_desmovs.c"
#include "fips_dhvs.c"
#include "fips_drbgvs.c"
#include "fips_dssvs.c"
#include "fips_ecdhvs.c"
#include "fips_ecdsavs.c"
#include "fips_gcmtest.c"
#include "fips_hmactest.c"
#include "fips_rngvs.c"
#include "fips_rsagtest.c"
#include "fips_rsastest.c"
#include "fips_rsavtest.c"
#include "fips_shatest.c"
#include "fips_test_suite.c"
typedef
struct
{
const
char
*
name
;
int
(
*
func
)(
int
argc
,
char
**
argv
);
}
ALGVS_FUNCTION
;
static
ALGVS_FUNCTION
algvs
[]
=
{
{
"fips_aesavs"
,
fips_aesavs_main
},
{
"fips_cmactest"
,
fips_cmactest_main
},
{
"fips_desmovs"
,
fips_desmovs_main
},
{
"fips_dhvs"
,
fips_dhvs_main
},
{
"fips_drbgvs"
,
fips_drbgvs_main
},
{
"fips_dssvs"
,
fips_dssvs_main
},
{
"fips_ecdhvs"
,
fips_ecdhvs_main
},
{
"fips_ecdsavs"
,
fips_ecdsavs_main
},
{
"fips_gcmtest"
,
fips_gcmtest_main
},
{
"fips_hmactest"
,
fips_hmactest_main
},
{
"fips_rngvs"
,
fips_rngvs_main
},
{
"fips_rsagtest"
,
fips_rsagtest_main
},
{
"fips_rsastest"
,
fips_rsastest_main
},
{
"fips_rsavtest"
,
fips_rsavtest_main
},
{
"fips_shatest"
,
fips_shatest_main
},
{
"fips_test_suite"
,
fips_test_suite_main
},
{
NULL
,
0
}
};
/* Argument parsing taken from apps/apps.c */
typedef
struct
args_st
{
char
**
data
;
int
count
;
}
ARGS
;
static
int
chopup_args
(
ARGS
*
arg
,
char
*
buf
,
int
*
argc
,
char
**
argv
[])
{
int
num
,
i
;
char
*
p
;
*
argc
=
0
;
*
argv
=
NULL
;
i
=
0
;
if
(
arg
->
count
==
0
)
{
arg
->
count
=
20
;
arg
->
data
=
(
char
**
)
OPENSSL_malloc
(
sizeof
(
char
*
)
*
arg
->
count
);
}
for
(
i
=
0
;
i
<
arg
->
count
;
i
++
)
arg
->
data
[
i
]
=
NULL
;
num
=
0
;
p
=
buf
;
for
(;;)
{
/* first scan over white space */
if
(
!*
p
)
break
;
while
(
*
p
&&
((
*
p
==
' '
)
||
(
*
p
==
'\t'
)
||
(
*
p
==
'\n'
)))
p
++
;
if
(
!*
p
)
break
;
/* The start of something good :-) */
if
(
num
>=
arg
->
count
)
{
fprintf
(
stderr
,
"Too many arguments!!
\n
"
);
return
0
;
}
arg
->
data
[
num
++
]
=
p
;
/* now look for the end of this */
if
((
*
p
==
'\''
)
||
(
*
p
==
'\"'
))
/* scan for closing quote */
{
i
=
*
(
p
++
);
arg
->
data
[
num
-
1
]
++
;
/* jump over quote */
while
(
*
p
&&
(
*
p
!=
i
))
p
++
;
*
p
=
'\0'
;
}
else
{
while
(
*
p
&&
((
*
p
!=
' '
)
&&
(
*
p
!=
'\t'
)
&&
(
*
p
!=
'\n'
)))
p
++
;
if
(
*
p
==
'\0'
)
p
--
;
else
*
p
=
'\0'
;
}
p
++
;
}
*
argc
=
num
;
*
argv
=
arg
->
data
;
return
(
1
);
}
static
int
run_prg
(
int
argc
,
char
**
argv
)
{
ALGVS_FUNCTION
*
t
;
const
char
*
prg_name
;
prg_name
=
strrchr
(
argv
[
0
],
'/'
);
if
(
prg_name
)
prg_name
++
;
else
prg_name
=
argv
[
0
];
for
(
t
=
algvs
;
t
->
name
;
t
++
)
{
if
(
!
strcmp
(
prg_name
,
t
->
name
))
return
t
->
func
(
argc
,
argv
);
}
return
-
100
;
}
int
main
(
int
argc
,
char
**
argv
)
{
char
buf
[
1024
];
char
**
args
=
argv
+
1
;
const
char
*
sname
=
"fipstests.sh"
;
ARGS
arg
;
int
xargc
;
char
**
xargv
;
int
lineno
=
0
,
badarg
=
0
;
int
nerr
=
0
,
quiet
=
0
,
verbose
=
0
;
FILE
*
in
=
NULL
;
if
(
*
args
&&
*
args
[
0
]
!=
'-'
)
return
run_prg
(
argc
-
1
,
args
);
while
(
!
badarg
&&
*
args
&&
*
args
[
0
]
==
'-'
)
{
if
(
!
strcmp
(
*
args
,
"-script"
))
{
if
(
args
[
1
])
{
args
++
;
sname
=
*
args
;
}
else
badarg
=
1
;
}
else
if
(
!
strcmp
(
*
args
,
"-quiet"
))
quiet
=
1
;
else
if
(
!
strcmp
(
*
args
,
"-verbose"
))
verbose
=
1
;
else
badarg
=
1
;
args
++
;
}
if
(
badarg
)
{
fprintf
(
stderr
,
"Error processing arguments
\n
"
);
return
1
;
}
in
=
fopen
(
sname
,
"r"
);
if
(
!
in
)
{
fprintf
(
stderr
,
"Error opening script file
\"
%s
\"\n
"
,
sname
);
return
1
;
}
arg
.
data
=
NULL
;
arg
.
count
=
0
;
while
(
fgets
(
buf
,
sizeof
(
buf
),
in
))
{
lineno
++
;
if
(
!
chopup_args
(
&
arg
,
buf
,
&
xargc
,
&
xargv
))
fprintf
(
stderr
,
"Error processing line %d
\n
"
,
lineno
);
else
{
int
rv
;
if
(
!
quiet
)
{
int
i
;
int
narg
=
verbose
?
xargc
:
xargc
-
2
;
printf
(
"Running command line:"
);
for
(
i
=
0
;
i
<
narg
;
i
++
)
printf
(
" %s"
,
xargv
[
i
]);
printf
(
"
\n
"
);
}
rv
=
run_prg
(
xargc
,
xargv
);
if
(
FIPS_module_mode
())
FIPS_module_mode_set
(
0
,
NULL
);
if
(
rv
!=
0
)
nerr
++
;
if
(
rv
==
-
100
)
fprintf
(
stderr
,
"ERROR: Command not found
\n
"
);
else
if
(
rv
!=
0
)
fprintf
(
stderr
,
"ERROR: returned %d
\n
"
,
rv
);
else
if
(
verbose
)
printf
(
"
\t
Command run successfully
\n
"
);
}
}
if
(
!
quiet
)
printf
(
"Completed with %d errors
\n
"
,
nerr
);
fclose
(
in
);
if
(
nerr
==
0
)
return
0
;
return
1
;
}
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录