mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-27 19:53:42 +00:00
Refactor code from test/ to utils/ since they are not just used by tests.
Also, adds a simple analog of verify_data. BUG=none TEST=none Review URL: http://codereview.chromium.org/578025
This commit is contained in:
@@ -2,19 +2,14 @@
|
|||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
SRCS=sha_tests.c verify_data.c signature_digest.c
|
SRCS=sha_tests.c
|
||||||
OBJS=$(SRCS:.c=.o)
|
OBJS=$(SRCS:.c=.o)
|
||||||
LIBS=$(TOP)/crypto/libcrypto.a $(TOP)/common/libcommon.a
|
LIBS=$(TOP)/crypto/libcrypto.a $(TOP)/common/libcommon.a
|
||||||
|
|
||||||
tests: sha_tests verify_data signature_digest
|
tests: sha_tests
|
||||||
|
|
||||||
sha_tests: sha_tests.c
|
sha_tests: sha_tests.c
|
||||||
$(CC) $(CFLAGS) -DNDEBUG $(INCLUDES) $< -o $@ $(LIBS)
|
$(CC) $(CFLAGS) -DNDEBUG $(INCLUDES) $< -o $@ $(LIBS)
|
||||||
|
|
||||||
verify_data: verify_data.c digest_utility.o
|
|
||||||
$(CC) $(CFLAGS) -DNDEBUG $(INCLUDES) $< -o $@ $(LIBS)
|
|
||||||
|
|
||||||
signature_digest: signature_digest.c
|
|
||||||
$(CC) $(CFLAGS) -DNDEBUG $(INCLUDES) $< -o $@ $(LIBS)
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) sha_tests verify_data signature_digest
|
rm -f $(OBJS) sha_tests verify_data signature_digest
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ hash_algos=( sha1 sha256 sha512 )
|
|||||||
key_lengths=( 1024 2048 4096 8192 )
|
key_lengths=( 1024 2048 4096 8192 )
|
||||||
TEST_FILE=test_file
|
TEST_FILE=test_file
|
||||||
TEST_FILE_SIZE=1000000
|
TEST_FILE_SIZE=1000000
|
||||||
UTILDIR=../utils/
|
UTIL_DIR=../utils/
|
||||||
|
|
||||||
# Generate RSA test keys of various lengths.
|
# Generate RSA test keys of various lengths.
|
||||||
function generate_keys {
|
function generate_keys {
|
||||||
@@ -21,7 +21,7 @@ function generate_keys {
|
|||||||
# Generate self-signed certificate from key.
|
# Generate self-signed certificate from key.
|
||||||
openssl req -batch -new -x509 -key key_rsa$i.pem -out key_rsa$i.crt
|
openssl req -batch -new -x509 -key key_rsa$i.pem -out key_rsa$i.crt
|
||||||
# Generate pre-processed key for use by RSA signature verification code.
|
# Generate pre-processed key for use by RSA signature verification code.
|
||||||
${UTILDIR}/dumpRSAPublicKey key_rsa$i.crt > key_rsa$i.keyb
|
${UTIL_DIR}/dumpRSAPublicKey key_rsa$i.crt > key_rsa$i.keyb
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@ function generate_signatures {
|
|||||||
do
|
do
|
||||||
for hashalgo in ${hash_algos[@]}
|
for hashalgo in ${hash_algos[@]}
|
||||||
do
|
do
|
||||||
./signature_digest $algorithmcounter $1 | openssl rsautl -sign -pkcs \
|
${UTIL_DIR}/signature_digest $algorithmcounter $1 | openssl rsautl -sign \
|
||||||
-inkey key_rsa${keylen}.pem > $1.rsa${keylen}\_${hashalgo}.sig
|
-pkcs -inkey key_rsa${keylen}.pem > $1.rsa${keylen}\_${hashalgo}.sig
|
||||||
let algorithmcounter=algorithmcounter+1
|
let algorithmcounter=algorithmcounter+1
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@@ -47,7 +47,7 @@ function test_signatures {
|
|||||||
for hashalgo in ${hash_algos[@]}
|
for hashalgo in ${hash_algos[@]}
|
||||||
do
|
do
|
||||||
echo "For RSA-$keylen and $hashalgo:"
|
echo "For RSA-$keylen and $hashalgo:"
|
||||||
./verify_data $algorithmcounter key_rsa${keylen}.keyb \
|
${UTIL_DIR}/verify_data $algorithmcounter key_rsa${keylen}.keyb \
|
||||||
${TEST_FILE}.rsa${keylen}\_${hashalgo}.sig ${TEST_FILE}
|
${TEST_FILE}.rsa${keylen}\_${hashalgo}.sig ${TEST_FILE}
|
||||||
let algorithmcounter=algorithmcounter+1
|
let algorithmcounter=algorithmcounter+1
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -3,10 +3,18 @@
|
|||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
LIBS=-lcrypto
|
LIBS=-lcrypto
|
||||||
|
FIRMWARELIBS=$(TOP)/crypto/libcrypto.a $(TOP)/common/libcommon.a
|
||||||
|
|
||||||
all: dumpRSAPublicKey
|
all: dumpRSAPublicKey verify_data signature_digest
|
||||||
|
|
||||||
dumpRSAPublicKey: dumpRSAPublicKey.c
|
dumpRSAPublicKey: dumpRSAPublicKey.c
|
||||||
$(CC) $(CFLAGS) $(LIBS) $< -o $@
|
$(CC) $(CFLAGS) $(LIBS) $< -o $@
|
||||||
|
|
||||||
|
verify_data: verify_data.c
|
||||||
|
$(CC) $(CFLAGS) -DNDEBUG $(INCLUDES) $< -o $@ $(FIRMWARELIBS)
|
||||||
|
|
||||||
|
signature_digest: signature_digest.c
|
||||||
|
$(CC) $(CFLAGS) -DNDEBUG $(INCLUDES) $< -o $@ $(FIRMWARELIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f dumpRSAPublicKey
|
rm -f dumpRSAPublicKey verify_data signature_digest
|
||||||
|
|||||||
13
utils/sign_data.sh
Executable file
13
utils/sign_data.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
if [ $# -ne 3 ]
|
||||||
|
then
|
||||||
|
echo "Usage: `basename $0` <algorithm> <key file> <input file>"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
./signature_digest $1 $3 | openssl rsautl -sign -pkcs -inkey $2
|
||||||
Reference in New Issue
Block a user