diff options
author | Matt Caswell <matt@openssl.org> | 2016-04-29 10:56:20 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-04-29 15:04:15 +0100 |
commit | 97a982e2eee2e04e8e41ae12665af417315a0f23 (patch) | |
tree | b51cc91f14d545cdc80ab64ad202457a5f181e44 /test/rmdtest.c | |
parent | 4cd5c3f4eef81c791a5041dc17ec27aa08540e42 (diff) |
Fix the tests to work with EBCDIC
Most of the tests already pass with EBCIDC but a few were trying to
write into read only memory.
Reviewed-by: Andy Polyakov <appro@openssl.org>
Diffstat (limited to 'test/rmdtest.c')
-rw-r--r-- | test/rmdtest.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/test/rmdtest.c b/test/rmdtest.c index 867a20eaae..c7db9e7294 100644 --- a/test/rmdtest.c +++ b/test/rmdtest.c @@ -75,16 +75,15 @@ int main(int argc, char *argv[]) # include <openssl/ebcdic.h> # endif -static char *test[] = { - "", - "a", - "abc", - "message digest", - "abcdefghijklmnopqrstuvwxyz", - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - "12345678901234567890123456789012345678901234567890123456789012345678901234567890", - NULL, +static char test[][100] = { + { "" }, + { "a" }, + { "abc" }, + { "message digest" }, + { "abcdefghijklmnopqrstuvwxyz" }, + { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" }, + { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" }, + { "12345678901234567890123456789012345678901234567890123456789012345678901234567890" } }; static char *ret[] = { @@ -101,30 +100,29 @@ static char *ret[] = { static char *pt(unsigned char *md); int main(int argc, char *argv[]) { - int i, err = 0; - char **P, **R; + unsigned int i; + int err = 0; + char **R; char *p; unsigned char md[RIPEMD160_DIGEST_LENGTH]; - P = test; R = ret; - i = 1; - while (*P != NULL) { + i = 0; + while (i < OSSL_NELEM(test)) { # ifdef CHARSET_EBCDIC - ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P)); + ebcdic2ascii(test[i], test[i], strlen(test[i])); # endif - EVP_Digest(&(P[0][0]), strlen((char *)*P), md, NULL, EVP_ripemd160(), + EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_ripemd160(), NULL); p = pt(md); if (strcmp(p, (char *)*R) != 0) { - printf("error calculating RIPEMD160 on '%s'\n", *P); + printf("error calculating RIPEMD160 on '%s'\n", test[i]); printf("got %s instead of %s\n", p, *R); err++; } else - printf("test %d ok\n", i); + printf("test %d ok\n", i + 1); i++; R++; - P++; } EXIT(err); } |