remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,34 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2006 - 2007 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 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.
|
||||
* 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.
|
||||
* 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. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS 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 INSTITUTE OR 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 SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS 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 INSTITUTE OR 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -102,17 +102,17 @@ check_rsa(const unsigned char *in, size_t len, RSA *rsa, int padding)
|
||||
keylen = RSA_private_encrypt(len, in, res, rsa, padding);
|
||||
if (keylen <= 0)
|
||||
errx(1, "failed to private encrypt: %d %d", (int)len, (int)keylen);
|
||||
|
||||
|
||||
if (keylen > RSA_size(rsa))
|
||||
errx(1, "keylen > RSA_size(rsa)");
|
||||
|
||||
|
||||
keylen = RSA_public_decrypt(keylen, res, res2, rsa, padding);
|
||||
if (keylen <= 0)
|
||||
errx(1, "failed to public decrypt: %d", (int)keylen);
|
||||
|
||||
|
||||
if (keylen != len)
|
||||
errx(1, "output buffer not same length: %d", (int)keylen);
|
||||
|
||||
|
||||
if (memcmp(res2, in, len) != 0)
|
||||
errx(1, "string not the same after decryption");
|
||||
|
||||
@@ -121,17 +121,17 @@ check_rsa(const unsigned char *in, size_t len, RSA *rsa, int padding)
|
||||
keylen = RSA_public_encrypt(len, in, res, rsa, padding);
|
||||
if (keylen <= 0)
|
||||
errx(1, "failed to public encrypt: %d", (int)keylen);
|
||||
|
||||
|
||||
if (keylen > RSA_size(rsa))
|
||||
errx(1, "keylen > RSA_size(rsa)");
|
||||
|
||||
|
||||
keylen = RSA_private_decrypt(keylen, res, res2, rsa, padding);
|
||||
if (keylen <= 0)
|
||||
errx(1, "failed to private decrypt: %d", (int)keylen);
|
||||
|
||||
if (keylen != len)
|
||||
errx(1, "output buffer not same length: %d", (int)keylen);
|
||||
|
||||
|
||||
if (memcmp(res2, in, len) != 0)
|
||||
errx(1, "string not the same after decryption");
|
||||
|
||||
@@ -153,24 +153,24 @@ read_key(ENGINE *engine, const char *rsa_key)
|
||||
size_t size;
|
||||
RSA *rsa;
|
||||
FILE *f;
|
||||
|
||||
|
||||
f = fopen(rsa_key, "r");
|
||||
if (f == NULL)
|
||||
err(1, "could not open file %s", rsa_key);
|
||||
rk_cloexec_file(f);
|
||||
|
||||
|
||||
size = fread(buf, 1, sizeof(buf), f);
|
||||
fclose(f);
|
||||
if (size == 0)
|
||||
err(1, "failed to read file %s", rsa_key);
|
||||
if (size == sizeof(buf))
|
||||
err(1, "key too long in file %s!", rsa_key);
|
||||
|
||||
|
||||
p = buf;
|
||||
rsa = d2i_RSAPrivateKey(NULL, &p, size);
|
||||
if (rsa == NULL)
|
||||
err(1, "failed to parse key in file %s", rsa_key);
|
||||
|
||||
|
||||
RSA_set_method(rsa, ENGINE_get_RSA(engine));
|
||||
|
||||
if (!key_blinding)
|
||||
@@ -204,7 +204,7 @@ main(int argc, char **argv)
|
||||
|
||||
if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &idx))
|
||||
usage(1);
|
||||
|
||||
|
||||
if (help_flag)
|
||||
usage(0);
|
||||
|
||||
@@ -230,7 +230,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (ENGINE_get_RSA(engine) == NULL)
|
||||
return 77;
|
||||
|
||||
|
||||
printf("rsa %s\n", ENGINE_get_RSA(engine)->name);
|
||||
|
||||
if (RAND_status() != 1)
|
||||
@@ -260,8 +260,8 @@ main(int argc, char **argv)
|
||||
gettimeofday(&tv2, NULL);
|
||||
timevalsub(&tv2, &tv1);
|
||||
|
||||
printf("time %lu.%06lu\n",
|
||||
(unsigned long)tv2.tv_sec,
|
||||
printf("time %lu.%06lu\n",
|
||||
(unsigned long)tv2.tv_sec,
|
||||
(unsigned long)tv2.tv_usec);
|
||||
|
||||
BN_free(e);
|
||||
@@ -289,8 +289,8 @@ main(int argc, char **argv)
|
||||
|
||||
timevalsub(&tv2, &tv1);
|
||||
|
||||
printf("time %lu.%06lu\n",
|
||||
(unsigned long)tv2.tv_sec,
|
||||
printf("time %lu.%06lu\n",
|
||||
(unsigned long)tv2.tv_sec,
|
||||
(unsigned long)tv2.tv_usec);
|
||||
|
||||
RSA_free(rsa);
|
||||
@@ -310,16 +310,16 @@ main(int argc, char **argv)
|
||||
*/
|
||||
{
|
||||
const unsigned char sha1[20] = {
|
||||
0x6d, 0x33, 0xf9, 0x40, 0x75, 0x5b, 0x4e, 0xc5, 0x90, 0x35,
|
||||
0x6d, 0x33, 0xf9, 0x40, 0x75, 0x5b, 0x4e, 0xc5, 0x90, 0x35,
|
||||
0x48, 0xab, 0x75, 0x02, 0x09, 0x76, 0x9a, 0xb4, 0x7d, 0x6b
|
||||
};
|
||||
|
||||
|
||||
check_rsa(sha1, sizeof(sha1), rsa, RSA_PKCS1_PADDING);
|
||||
}
|
||||
|
||||
for (i = 0; i < 128; i++) {
|
||||
unsigned char sha1[20];
|
||||
|
||||
|
||||
RAND_bytes(sha1, sizeof(sha1));
|
||||
check_rsa(sha1, sizeof(sha1), rsa, RSA_PKCS1_PADDING);
|
||||
}
|
||||
|
Reference in New Issue
Block a user