~ubuntu-branches/ubuntu/karmic/nss/karmic

« back to all changes in this revision

Viewing changes to mozilla/security/nss/tests/tools/tools.sh

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Fabien Tassin, Alexander Sack
  • Date: 2009-01-11 15:06:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090111150617-iz4lw05qgy2odorl
Tags: 3.12.2~rc1-0ubuntu1
* New upstream snapshot: 3.12.2 RC1

[ Fabien Tassin <fta@ubuntu.com> ]
* Remove patch applied upstream:
  - drop debian/patches/80_security_tools.patch
  - update debian/patches/series
* Update diverged patches:
  - update debian/patches/38_kbsd.patch
  - update debian/patches/38_mips64_build.patch
* Add new symbols to symbols file
  - update debian/libnss3-1d.symbols

[ Alexander Sack <asac@ubuntu.com> ]
* disable soname patch to become binary compatible with upstream
  - update debian/patches/series
* flip links: libnss3.so <- libnss3.so.1d (before: libnss3.so ->
  libnss3.so.1d); same link flipping was done for all other previously
  soname patched libs: libnssutil3.so, libsmime3.so.1d, libssl3.so.1d
  - update debian/libnss3-1d.links
  - update debian/libnss3-1d.symbols
* properly transition links in preinst and postrm; also cover abort-
  cases in the other maintainer scripts
  - add debian/libnss3-1d.postinst
  - add debian/libnss3-1d.postrm
  - add debian/libnss3-1d.preinst
  - add debian/libnss3-1d.prerm
* remove hack from debian/rules that debian uses to recreate
  libsoftokn3.so with a versioned SONAME
  - update debian/rules
* install the unversioned .so binaries
  - update debian/rules
* only install the 4 main libraries into /usr/lib; all the others
  go to pkglibdir
  - update debian/rules
* higher bar for libnspr4 Build-Depend to >= 4.7.3~, which is
  the version where the soname droppage is going to happen
  - update debian/control
* explitily pass libraries to be used for dpkg-gensymbols run of
  dh_makeshlibs
  - update debian/rules
* fix lintian complain about no-shlibs-control-file
  - update debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#
42
42
# mozilla/security/nss/tests/tools/tools.sh
43
43
#
44
 
# Script to test basic functionallity of NSS tools 
 
44
# Script to test basic functionality of NSS tools 
45
45
#
46
46
# needs to work on all Unix and Windows platforms
47
47
#
55
55
#   NOTE .... unexpected behavior
56
56
########################################################################
57
57
 
 
58
  export pkcs12v2pbeWithSha1And128BitRc4=\
 
59
"PKCS #12 V2 PBE With Sha1 and 128 Bit RC4"
 
60
 
 
61
  export pkcs12v2pbeWithSha1And40BitRc4=\
 
62
"PKCS #12 V2 PBE With Sha1 and 40 Bit RC4"
 
63
 
 
64
  export pkcs12v2pbeWithSha1AndTripleDESCBC=\
 
65
"PKCS #12 V2 PBE With Sha1 and Triple DES CBC"
 
66
 
 
67
  export pkcs12v2pbeWithSha1And128BitRc2Cbc=\
 
68
"PKCS #12 V2 PBE With Sha1 and 128 Bit RC2 CBC"
 
69
 
 
70
  export pkcs12v2pbeWithSha1And40BitRc2Cbc=\
 
71
"PKCS #12 V2 PBE With Sha1 and 40 Bit RC2 CBC"
 
72
 
 
73
  export pkcs12v2pbeWithMd2AndDESCBC=\
 
74
"PKCS #5 Password Based Encryption with MD2 and DES CBC"
 
75
 
 
76
  export pkcs12v2pbeWithMd5AndDESCBC=\
 
77
"PKCS #5 Password Based Encryption with MD5 and DES CBC"
 
78
 
 
79
  export pkcs12v2pbeWithSha1AndDESCBC=\
 
80
"PKCS #5 Password Based Encryption with SHA1 and DES CBC"
 
81
  
 
82
  export pkcs5pbeWithMD2AndDEScbc=\
 
83
"PKCS #5 Password Based Encryption with MD2 and DES CBC"
 
84
 
 
85
  export pkcs5pbeWithMD5AndDEScbc=\
 
86
"PKCS #5 Password Based Encryption with MD5 and DES CBC"
 
87
 
 
88
  export pkcs5pbeWithSha1AndDEScbc=\
 
89
"PKCS #5 Password Based Encryption with SHA1 and DES CBC"
 
90
 
58
91
############################## tools_init ##############################
59
92
# local shell function to initialize this script 
60
93
########################################################################
104
137
  cd ${TOOLSDIR}
105
138
}
106
139
 
107
 
############################## tools_p12 ###############################
108
 
# local shell function to test basic functionality of pk12util
109
 
########################################################################
110
 
tools_p12()
111
 
{
112
 
  echo "$SCRIPTNAME: Exporting Alice's email cert & key------------------"
113
 
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} -k ${R_PWFILE} \\"
114
 
  echo "         -w ${R_PWFILE}"
115
 
  ${BINDIR}/pk12util -o Alice.p12 -n "Alice" -d ${P_R_ALICEDIR} -k ${R_PWFILE} \
116
 
           -w ${R_PWFILE} 2>&1 
117
 
  ret=$?
118
 
  html_msg $ret 0 "Exporting Alice's email cert & key (pk12util -o)"
119
 
  check_tmpfile
120
 
 
121
 
  echo "$SCRIPTNAME: Importing Alice's email cert & key -----------------"
122
 
  echo "pk12util -i Alice.p12 -d ${P_R_COPYDIR} -k ${R_PWFILE} -w ${R_PWFILE}"
123
 
  ${BINDIR}/pk12util -i Alice.p12 -d ${P_R_COPYDIR} -k ${R_PWFILE} -w ${R_PWFILE} 2>&1
124
 
  ret=$?
125
 
  html_msg $ret 0 "Importing Alice's email cert & key (pk12util -i)"
126
 
  check_tmpfile
127
 
 
128
 
  echo "$SCRIPTNAME: Listing Alice's pk12 file -----------------"
129
 
  echo "pk12util -l Alice.p12 -w ${R_PWFILE}"
130
 
  ${BINDIR}/pk12util -l Alice.p12 -w ${R_PWFILE} 2>&1
131
 
  ret=$?
132
 
  html_msg $ret 0 "Listing Alice's pk12 file (pk12util -l)"
133
 
  check_tmpfile
 
140
########################## list_p12_file ###############################
 
141
# List the key and cert in the specified p12 file
 
142
########################################################################
 
143
list_p12_file()
 
144
{
 
145
  echo "$SCRIPTNAME: Listing Alice's pk12 file"
 
146
  echo "pk12util -l ${1} -w ${R_PWFILE}"
 
147
    
 
148
  ${BINDIR}/pk12util -l ${1} -w ${R_PWFILE} 2>&1
 
149
  ret=$?
 
150
  html_msg $ret 0 "Listing ${1} (pk12util -l)"
 
151
  check_tmpfile
 
152
}
 
153
 
 
154
########################################################################
 
155
# Import the key and cert from the specified p12 file
 
156
########################################################################
 
157
import_p12_file()
 
158
{
 
159
  echo "$SCRIPTNAME: Importing Alice's pk12 ${1} file"
 
160
  echo "pk12util -i ${1} -d ${P_R_COPYDIR} -k ${R_PWFILE} -w ${R_PWFILE}"
 
161
    
 
162
  ${BINDIR}/pk12util -i ${1} -d ${P_R_COPYDIR} -k ${R_PWFILE} -w ${R_PWFILE} 2>&1
 
163
  ret=$?
 
164
  html_msg $ret 0 "Importing ${1} (pk12util -i)"
 
165
  check_tmpfile
 
166
}
 
167
 
 
168
########################################################################
 
169
# Export the key and cert to a p12 file using default ciphers
 
170
########################################################################
 
171
export_with_default_ciphers() 
 
172
{
 
173
  echo "$SCRIPTNAME: Exporting Alice's key & cert with [default:default] (pk12util -o)"
 
174
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
 
175
  echo "         -k ${R_PWFILE} -w ${R_PWFILE}"
 
176
  ${BINDIR}/pk12util -o Alice.p12 -n "Alice" -d ${P_R_ALICEDIR} \
 
177
                       -k ${R_PWFILE} -w ${R_PWFILE} 2>&1  
 
178
  ret=$?  
 
179
  html_msg $ret 0 "Exporting Alices's key & cert with [default:default] (pk12util -o)"
 
180
  check_tmpfile
 
181
  return $ret
 
182
}
 
183
 
 
184
########################################################################
 
185
# Exports key/cert to a p12 file, the key encryption cipher is specified
 
186
# and the cert encryption cipher is blank for default.
 
187
########################################################################
 
188
export_with_key_cipher() 
 
189
{
 
190
  # $1 key encryption cipher   
 
191
  echo "$SCRIPTNAME: Exporting with [${1}:default]"
 
192
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
 
193
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -c ${1}"
 
194
  ${BINDIR}/pk12util -o Alice.p12 -n "Alice" -d ${P_R_ALICEDIR} \
 
195
                     -k ${R_PWFILE} -w ${R_PWFILE} -c "${1}" 2>&1  
 
196
  ret=$?  
 
197
  html_msg $ret 0 "Exporting with [${1}:default] (pk12util -o)"
 
198
  check_tmpfile
 
199
  return $ret
 
200
}
 
201
 
 
202
########################################################################
 
203
# Exports key/cert to a p12 file, the key encryption cipher is left
 
204
# empty for default and the cert encryption cipher is specified.
 
205
########################################################################
 
206
export_with_cert_cipher() 
 
207
{
 
208
  # $1 certificate encryption cipher
 
209
  echo "$SCRIPTNAME: Exporting with [default:${1}]"
 
210
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
 
211
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -C ${1}"
 
212
  ${BINDIR}/pk12util -o Alice.p12 -n "Alice" -d ${P_R_ALICEDIR} \
 
213
                     -k ${R_PWFILE} -w ${R_PWFILE} -C "${1}" 2>&1  
 
214
  ret=$?  
 
215
  html_msg $ret 0 "Exporting with [default:${1}] (pk12util -o)"
 
216
  check_tmpfile
 
217
  return $ret
 
218
}
 
219
 
 
220
########################################################################
 
221
# Exports key/cert to a p12 file, both the key encryption cipher and
 
222
# the cert encryption cipher are specified.
 
223
########################################################################
 
224
export_with_both_key_and_cert_cipher()
 
225
{
 
226
  # $1 key encryption cipher or ""
 
227
  # $2 certificate encryption cipher or ""
 
228
  
 
229
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
 
230
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -c ${1} -C ${2}"     
 
231
  ${BINDIR}/pk12util -o Alice.p12 -n Alice -d ${P_R_ALICEDIR} \
 
232
                       -k ${R_PWFILE} -w ${R_PWFILE} \
 
233
                       -c "${1}" -C "${2}" 2>&1  
 
234
  ret=$?    
 
235
  html_msg $ret 0 "Exporting with [${1}:${2}] (pk12util -o)"
 
236
  check_tmpfile
 
237
  return $ret
 
238
}
 
239
 
 
240
########################################################################
 
241
# Exports key and cert to a p12 file, both the key encryption cipher 
 
242
# and the cert encryption cipher are specified. The key and cert are
 
243
# imported and the p12 file is listed
 
244
########################################################################
 
245
export_list_import()
 
246
{
 
247
  # $1 key encryption cipher
 
248
  # $2 certificate encryption cipher
 
249
    
 
250
  if [[ "${1}" != "" && "${2}" != "" ]]; then
 
251
      export_with_both_key_and_cert_cipher "${1}" "${2}"
 
252
  elif [[ "${1}" != "" && "${2}" = "" ]]; then
 
253
      export_with_key_cipher "${1}"
 
254
  elif [[ "${1}" = "" && "${2}" != "" ]]; then
 
255
      export_with_cert_cipher "${2}"
 
256
  else
 
257
      export_with_default_ciphers
 
258
  fi
 
259
    
 
260
  list_p12_file Alice.p12
 
261
  import_p12_file Alice.p12
 
262
}
 
263
 
 
264
########################################################################
 
265
# Export using the pkcs5pbe ciphers for key and certificate encryption.
 
266
# List the contents of and import from the p12 file.
 
267
########################################################################
 
268
tools_p12_export_list_import_all_pkcs5pbe_ciphers()
 
269
{  
 
270
  # specify each on key and cert cipher
 
271
  for key_cipher in "${pkcs5pbeWithMD2AndDEScbc}" \
 
272
                    "${pkcs5pbeWithMD5AndDEScbc}" \
 
273
                    "${pkcs5pbeWithSha1AndDEScbc}"\
 
274
                    ""; do
 
275
      for cert_cipher in "${pkcs5pbeWithMD2AndDEScbc}" \
 
276
                         "${pkcs5pbeWithMD5AndDEScbc}" \
 
277
                         "${pkcs5pbeWithSha1AndDEScbc}" \
 
278
                         ""\
 
279
                         "null"; do
 
280
            export_list_import "${key_cipher}" "${cert_cipher}"
 
281
      done       
 
282
  done
 
283
}
 
284
 
 
285
########################################################################
 
286
# Export using the pkcs5v2 ciphers for key and certificate encryption.
 
287
# List the contents of and import from the p12 file.
 
288
########################################################################
 
289
tools_p12_export_list_import_all_pkcs5v2_ciphers()
 
290
{
 
291
  # These should pass
 
292
  for key_cipher in\
 
293
    RC2-CBC \
 
294
    DES-EDE3-CBC \
 
295
    AES-128-CBC \
 
296
    AES-192-CBC \
 
297
    AES-256-CBC \
 
298
    CAMELLIA-128-CBC \
 
299
    CAMELLIA-192-CBC \
 
300
    CAMELLIA-256-CBC; do
 
301
 
 
302
#---------------------------------------------------------------
 
303
# Bug 452464 - pk12util -o fails when -C option specifies AES or
 
304
# Camellia ciphers
 
305
# FIXME Restore these to the list
 
306
#    AES-128-CBC, \
 
307
#    AES-192-CBC, \
 
308
#    AES-256-CBC, \
 
309
#    CAMELLIA-128-CBC, \
 
310
#    CAMELLIA-192-CBC, \
 
311
#    CAMELLIA-256-CBC, \
 
312
#  when 452464 is fixed
 
313
#---------------------------------------------------------------  
 
314
    for cert_cipher in \
 
315
      RC2-CBC \
 
316
      DES-EDE3-CBC \
 
317
      null; do
 
318
          export_list_import ${key_cipher} ${cert_cipher}
 
319
        done
 
320
  done
 
321
}
 
322
 
 
323
########################################################################
 
324
# Export using the pkcs12v2pbe ciphers for key and certificate encryption.
 
325
# List the contents of and import from the p12 file.
 
326
########################################################################
 
327
tools_p12_export_list_import_all_pkcs12v2pbe_ciphers()
 
328
 
329
#---------------------------------------------------------------
 
330
# Bug 452471 - pk12util -o fails when -c option specifies pkcs12v2 PBE ciphers
 
331
# FIXME - Restore these to the list 
 
332
#                "${pkcs12v2pbeWithSha1And128BitRc4}" \
 
333
#                "${pkcs12v2pbeWithSha1And40BitRc4}" \
 
334
#                    "${pkcs12v2pbeWithSha1AndTripleDESCBC}" \
 
335
#                "${pkcs12v2pbeWithSha1And128BitRc2Cbc}" \
 
336
#                "${pkcs12v2pbeWithSha1And40BitRc2Cbc}" \
 
337
#                "${pkcs12v2pbeWithMd2AndDESCBC}" \
 
338
#                "${pkcs12v2pbeWithMd5AndDESCBC}" \
 
339
#                "${pkcs12v2pbeWithSha1AndDESCBC}" \
 
340
#                ""; do
 
341
# when 452471 is fixed
 
342
#---------------------------------------------------------------
 
343
#  for key_cipher in \
 
344
    key_cipher=""
 
345
    for cert_cipher in "${pkcs12v2pbeWithSha1And128BitRc4}" \
 
346
                  "${pkcs12v2pbeWithSha1And40BitRc4}" \
 
347
                  "${pkcs12v2pbeWithSha1AndTripleDESCBC}" \
 
348
                  "${pkcs12v2pbeWithSha1And128BitRc2Cbc}" \
 
349
                  "${pkcs12v2pbeWithSha1And40BitRc2Cbc}" \
 
350
                  "${pkcs12v2pbeWithMd2AndDESCBC}" \
 
351
                  "${pkcs12v2pbeWithMd5AndDESCBC}" \
 
352
                  "${pkcs12v2pbeWithSha1AndDESCBC}" \
 
353
                  ""\
 
354
                  "null"; do        
 
355
          export_list_import "${key_cipher}" "${key_cipher}" 
 
356
        done
 
357
  #done
 
358
}
 
359
 
 
360
#########################################################################
 
361
# Export with no encryption on key should fail but on cert should pass
 
362
#########################################################################
 
363
tools_p12_export_with_null_ciphers()
 
364
{
 
365
  # use null as the key encryption algorithm default for the cert one
 
366
  # should fail
 
367
  
 
368
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
 
369
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -c null"     
 
370
  ${BINDIR}/pk12util -o Alice.p12 -n Alice -d ${P_R_ALICEDIR} \
 
371
                       -k ${R_PWFILE} -w ${R_PWFILE} \
 
372
                       -c null 2>&1  
 
373
  ret=$?
 
374
  html_msg $ret 30 "Exporting with [null:default] (pk12util -o)"
 
375
  check_tmpfile
 
376
 
 
377
  # use default as the key encryption algorithm null for the cert one
 
378
  # should pass
 
379
  
 
380
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
 
381
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -C null"     
 
382
  ${BINDIR}/pk12util -o Alice.p12 -n Alice -d ${P_R_ALICEDIR} \
 
383
                       -k ${R_PWFILE} -w ${R_PWFILE} \
 
384
                       -C null 2>&1  
 
385
  ret=$?
 
386
  html_msg $ret 0 "Exporting with [default:null] (pk12util -o)"
 
387
  check_tmpfile
 
388
 
 
389
}
 
390
 
 
391
#########################################################################
 
392
# Exports using the default key and certificate encryption ciphers.
 
393
# Imports from  and lists the contents of the p12 file.
 
394
# Repeats the test with ECC if enabled.
 
395
########################################################################
 
396
tools_p12_export_list_import_with_default_ciphers()
 
397
{
 
398
  echo "$SCRIPTNAME: Exporting Alice's email cert & key - default ciphers"
 
399
  
 
400
  export_list_import "" ""
134
401
 
135
402
  if [ -n "$NSS_ENABLE_ECC" ] ; then
136
403
      echo "$SCRIPTNAME: Exporting Alice's email EC cert & key---------------"
156
423
      html_msg $ret 0 "Listing Alice's pk12 EC file (pk12util -l)"
157
424
      check_tmpfile
158
425
  fi
 
426
}
159
427
 
 
428
############################## tools_p12 ###############################
 
429
# local shell function to test basic functionality of pk12util
 
430
########################################################################
 
431
tools_p12()
 
432
{
 
433
  tools_p12_export_list_import_with_default_ciphers
 
434
  tools_p12_export_list_import_all_pkcs5v2_ciphers
 
435
  tools_p12_export_list_import_all_pkcs5pbe_ciphers
 
436
  tools_p12_export_list_import_all_pkcs12v2pbe_ciphers
 
437
  tools_p12_export_with_null_ciphers
160
438
}
161
439
 
162
440
############################## tools_sign ##############################
240
518
################## main #################################################
241
519
 
242
520
tools_init
243
 
 
244
521
tools_p12
245
 
 
246
522
tools_sign
247
523
tools_cleanup
248
524