blob: cdaca023963721916d013aab55ef91e73d877f39 [file] [log] [blame]
Brian Carlstrom98d58bb2010-03-09 09:56:55 -08001#!/bin/bash
2#
3# Copyright (C) 2010 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18#
19# Android testssl.sh driver script for openssl's testssl
20#
21# based on openssl's test/testss script and test/Makefile's test_ssl target
22#
23
24set -e
25trap "echo Exiting on unexpected error." ERR
26
27device=/mnt/sdcard/android.testssl
28
29digest='-sha1'
30reqcmd="adb shell /system/bin/openssl req"
31x509cmd="adb shell /system/bin/openssl x509 $digest"
32
33CAkey="$device/keyCA.ss"
34CAcert="$device/certCA.ss"
35CAreq="$device/reqCA.ss"
36CAconf="$device/CAss.cnf"
37
38Uconf="$device/Uss.cnf"
39Ureq="$device/reqU.ss"
40Ukey="$device/keyU.ss"
41Ucert="$device/certU.ss"
42
43echo
44echo "setting up"
45adb shell rm -r $device
46adb shell mkdir $device
47
48echo
49echo "pushing test files to device"
50adb push . $device
51
52echo
53echo "make a certificate request using 'req'"
54adb shell "echo \"string to make the random number generator think it has entropy\" >> $device/.rnd"
55req_new='-new'
56$reqcmd -config $CAconf -out $CAreq -keyout $CAkey $req_new
57
58echo
59echo "convert the certificate request into a self signed certificate using 'x509'"
60$x509cmd -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey -extfile $CAconf -extensions v3_ca
61
62echo
63echo "make a user certificate request using 'req'"
64$reqcmd -config $Uconf -out $Ureq -keyout $Ukey $req_new
65
66echo
67echo "sign user certificate request with the just created CA via 'x509'"
68$x509cmd -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey -extfile $Uconf -extensions v3_ee
69
70echo
71echo "running testssl"
72./testssl $Ukey $Ucert $CAcert
73
74echo
75echo "cleaning up"
76adb shell rm -r $device