Revision e1b43d3a

View differences:

res/layout/activity_main.xml
7 7
    <TableLayout
8 8
        android:layout_width="match_parent"
9 9
        android:layout_height="wrap_content"
10
        android:paddingBottom="5dip"
11
        android:paddingTop="5dip" >
10
        android:padding="5dip" >
11

  
12
        <TableRow
13
            android:layout_width="wrap_content"
14
            android:layout_height="wrap_content" >
15

  
16
            <LinearLayout
17
                android:layout_width="wrap_content"
18
                android:layout_height="wrap_content"
19
                android:layout_gravity="right|center_vertical" >
20

  
21
                <TextView
22
                    android:layout_width="wrap_content"
23
                    android:layout_height="match_parent"
24
                    android:text="Key Type:"
25
                    android:typeface="serif" />
26
            </LinearLayout>
27

  
28
            <LinearLayout
29
                android:layout_width="wrap_content"
30
                android:layout_height="wrap_content" >
31

  
32
                <TextView
33
                    android:id="@+id/key_type"
34
                    android:layout_width="wrap_content"
35
                    android:layout_height="match_parent"
36
                    android:paddingRight="15dip"
37
                    android:textStyle="bold" />
38

  
39
                <TextView
40
                    android:layout_width="wrap_content"
41
                    android:layout_height="match_parent"
42
                    android:layout_gravity="right|center_vertical"
43
                    android:text="Signature Type:"
44
                    android:typeface="serif" />
45

  
46
                <TextView
47
                    android:id="@+id/signature_type"
48
                    android:layout_width="wrap_content"
49
                    android:layout_height="match_parent"
50
                    android:paddingRight="15dip"
51
                    android:textStyle="bold" />
52

  
53
                <TextView
54
                    android:layout_width="wrap_content"
55
                    android:layout_height="match_parent"
56
                    android:layout_gravity="right|center_vertical"
57
                    android:text="Version:"
58
                    android:typeface="serif" />
59

  
60
                <TextView
61
                    android:id="@+id/version"
62
                    android:layout_width="wrap_content"
63
                    android:layout_height="match_parent"
64
                    android:textStyle="bold" />
65
            </LinearLayout>
66
        </TableRow>
67

  
68
        <TableRow
69
            android:layout_width="wrap_content"
70
            android:layout_height="wrap_content" >
71

  
72
            <LinearLayout
73
                android:layout_width="wrap_content"
74
                android:layout_height="wrap_content"
75
                android:layout_gravity="right|center_vertical" >
76

  
77
                <TextView
78
                    android:layout_width="wrap_content"
79
                    android:layout_height="match_parent"
80
                    android:text="Created:"
81
                    android:typeface="serif" />
82
            </LinearLayout>
83

  
84
            <LinearLayout
85
                android:layout_width="wrap_content"
86
                android:layout_height="wrap_content" >
87

  
88
                <TextView
89
                    android:id="@+id/created"
90
                    android:layout_width="wrap_content"
91
                    android:layout_height="match_parent"
92
                    android:paddingRight="15dip"
93
                    android:textStyle="bold" />
94

  
95
                <TextView
96
                    android:layout_width="wrap_content"
97
                    android:layout_height="match_parent"
98
                    android:layout_gravity="right|center_vertical"
99
                    android:text="Expires:"
100
                    android:typeface="serif" />
101

  
102
                <TextView
103
                    android:id="@+id/expires"
104
                    android:layout_width="wrap_content"
105
                    android:layout_height="match_parent"
106
                    android:textStyle="bold" />
107
            </LinearLayout>
108
        </TableRow>
12 109

  
13 110
        <TableRow
14 111
            android:layout_width="wrap_content"
......
18 115
                android:layout_width="wrap_content"
19 116
                android:layout_height="wrap_content"
20 117
                android:layout_gravity="right|center_vertical"
21
                android:text="SubjectDN:"
22
                android:typeface="monospace" />
118
                android:text="Subject:"
119
                android:typeface="serif" />
23 120

  
24 121
            <TextView
25 122
                android:id="@+id/subjectdn"
123
                android:layout_width="match_parent"
124
                android:layout_height="wrap_content"
125
                android:textStyle="bold" />
126
        </TableRow>
127

  
128
        <TableRow
129
            android:layout_width="wrap_content"
130
            android:layout_height="wrap_content" >
131

  
132
            <TextView
26 133
                android:layout_width="wrap_content"
27
                android:layout_height="wrap_content" />
134
                android:layout_height="wrap_content"
135
                android:layout_gravity="right|center_vertical"
136
                android:text="Issuer:"
137
                android:typeface="serif" />
138

  
139
            <TextView
140
                android:id="@+id/issuerdn"
141
                android:layout_width="match_parent"
142
                android:layout_height="wrap_content"
143
                android:textStyle="bold" />
144
        </TableRow>
145

  
146
        <TableRow
147
            android:layout_width="wrap_content"
148
            android:layout_height="wrap_content" >
149

  
150
            <TextView
151
                android:layout_width="wrap_content"
152
                android:layout_height="wrap_content"
153
                android:layout_gravity="right|center_vertical"
154
                android:text="Serial:"
155
                android:typeface="serif" />
156

  
157
            <TextView
158
                android:id="@+id/serial"
159
                android:layout_width="match_parent"
160
                android:layout_height="wrap_content"
161
                android:textStyle="bold" />
28 162
        </TableRow>
29 163

  
30 164
        <TableRow
......
35 169
                android:layout_width="wrap_content"
36 170
                android:layout_height="wrap_content"
37 171
                android:layout_gravity="right|center_vertical"
38
                android:text="IssuerDN:"
172
                android:text="MD5:"
173
                android:typeface="serif" />
174

  
175
            <TextView
176
                android:id="@+id/MD5"
177
                android:layout_width="match_parent"
178
                android:layout_height="wrap_content"
179
                android:textStyle="bold"
39 180
                android:typeface="monospace" />
181
        </TableRow>
182

  
183
        <TableRow
184
            android:layout_width="wrap_content"
185
            android:layout_height="wrap_content" >
40 186

  
41 187
            <TextView
42
                android:id="@+id/issuerdn"
43 188
                android:layout_width="wrap_content"
44
                android:layout_height="wrap_content" />
189
                android:layout_height="wrap_content"
190
                android:layout_gravity="right|center_vertical"
191
                android:text="SHA1:"
192
                android:typeface="serif" />
193

  
194
            <TextView
195
                android:id="@+id/sha1"
196
                android:layout_width="match_parent"
197
                android:layout_height="wrap_content"
198
                android:textStyle="bold"
199
                android:typeface="monospace" />
200
        </TableRow>
201

  
202
        <TableRow
203
            android:layout_width="wrap_content"
204
            android:layout_height="wrap_content" >
205

  
206
            <TextView
207
                android:layout_width="wrap_content"
208
                android:layout_height="wrap_content"
209
                android:layout_gravity="right|center_vertical"
210
                android:text="SHA256:"
211
                android:typeface="serif" />
212

  
213
            <TextView
214
                android:id="@+id/sha256"
215
                android:layout_width="match_parent"
216
                android:layout_height="wrap_content"
217
                android:textStyle="bold"
218
                android:typeface="monospace" />
45 219
        </TableRow>
46 220
    </TableLayout>
47 221

  
src/info/guardianproject/checkey/MainActivity.java
129 129
        X509Certificate[] certs = getX509Certificates(activity, packageName);
130 130
        if (certs == null || certs.length < 1)
131 131
            return;
132
        // for now, just support the first cert since that is far and away
133
        // the
134
        // most common
132
        /*
133
         * for now, just support the first cert since that is far and away the
134
         * most common
135
         */
135 136
        X509Certificate cert = certs[0];
137

  
138
        PublicKey publickey = cert.getPublicKey();
139
        int size;
140
        if (publickey.getAlgorithm().equals("RSA"))
141
            size = ((RSAPublicKey) publickey).getModulus().bitLength();
142
        else
143
            size = publickey.getEncoded().length * 7; // bad estimate
144

  
145
        TextView algorithm = (TextView) activity.findViewById(R.id.key_type);
146
        algorithm.setText(publickey.getAlgorithm() + " " + String.valueOf(size) + "bit");
147
        TextView keySize = (TextView) activity.findViewById(R.id.signature_type);
148
        keySize.setText(cert.getSigAlgName());
149
        TextView version = (TextView) activity.findViewById(R.id.version);
150
        version.setText(String.valueOf(cert.getVersion()));
151

  
136 152
        TextView issuerdn = (TextView) activity.findViewById(R.id.issuerdn);
137 153
        issuerdn.setText(cert.getIssuerDN().getName());
138 154
        TextView subjectdn = (TextView) activity.findViewById(R.id.subjectdn);
139 155
        subjectdn.setText(cert.getSubjectDN().getName());
156
        TextView serial = (TextView) activity.findViewById(R.id.serial);
157
        serial.setText(cert.getSerialNumber().toString(16));
158
        TextView created = (TextView) activity.findViewById(R.id.created);
159
        created.setText(cert.getNotBefore().toLocaleString());
160
        TextView expires = (TextView) activity.findViewById(R.id.expires);
161
        expires.setText(cert.getNotAfter().toLocaleString());
162

  
163
        TextView md5 = (TextView) activity.findViewById(R.id.MD5);
164
        md5.setText(Utils.getCertificateFingerprint(cert, "MD5"));
165
        TextView sha1 = (TextView) activity.findViewById(R.id.sha1);
166
        sha1.setText(Utils.getCertificateFingerprint(cert, "SHA1"));
167
        TextView sha256 = (TextView) activity.findViewById(R.id.sha256);
168
        sha256.setText(Utils.getCertificateFingerprint(cert, "SHA-256"));
140 169
    }
141 170

  
142 171
    @SuppressLint("WorldReadableFiles")

Also available in: Unified diff