summaryrefslogtreecommitdiffstats
path: root/dogtag/common-ui/shared/admin/console/config/sizepanel.vm
blob: 1dee1ce6b2c6f2d1ce9e418b6c304a6ca979c3c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
<!-- --- BEGIN COPYRIGHT BLOCK ---
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; version 2 of the License.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License along
     with this program; if not, write to the Free Software Foundation, Inc.,
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

     Copyright (C) 2007 Red Hat, Inc.
     All rights reserved.
     --- END COPYRIGHT BLOCK --- -->

<style type="text/css">
div#advance
{
  margin: 0px 20px 0px 20px;
  display: none;
}
div#simple
{
  margin: 0px 20px 0px 20px;
  display: block;
}
</style>

<SCRIPT type="text/JavaScript">

var rsalist="${rsalist}";
var ecclist="${ecclist}"; 
var curvelist="${curvelist}";
var displaycurvelist = "${displaycurvelist}";
var rsaTags = "${rsaTags}";
var additionalMessage = "";
if (rsaTags.length > 0) {
  additionalMessage = (rsaTags.indexOf(",") != -1)?
    "<p><b>IMPORTANT:</b> <i>Currently, the Audit Log Signing, Transport, and Storage functionality <b>ONLY</b> support RSA keys.  Users that require ECC keys <b>MUST</b> first select the ECC key type and then verify on the Advanced tab that RSA keys are selected for the Audit Log Signing Certificate, Transport Certificate, and Storage Certificate. All other keys can be ECC.</i>":
    "<p><b>IMPORTANT:</b> <i>Currently, the Audit Log Signing functionality <b>ONLY</b> supports RSA keys.  Users that require ECC keys <b>MUST</b> first select the ECC key type and then verify on the Advanced tab that an RSA key is selected for the Audit Log Signing Certificate. All other keys can be ECC.</i>";
}

function myOnLoad() {
   var form = document.forms[0];
   var keyTypeSelect = form.elements['keytype'];

   setSigningAlgOptions(keyTypeSelect.value, "commontag");
   setAllSigningAlgOptions(keyTypeSelect.value);

   setAlgOptions(keyTypeSelect.value, "commontag");
   setAllAlgOptions(keyTypeSelect.value);
}

function performPanel() {
    with (document.forms[0]) {
        submit();
    }
}

function toggleLayer(whichLayer)
{
  if (document.getElementById) {
    // this is the way the standards work
    var style2 = document.getElementById(whichLayer).style;
    if (style2.display == "block") {
      style2.display = "none";
    } else {
      style2.display = "block";
    }
  }
}

function toggleLayer1(whichLayer)
{
  if (document.getElementById) {
    // this is the way the standards work
    var style2 = document.getElementById(whichLayer).style;
    if (style2.display == "block") {
      style2.display = "none";
    } else if (style2.display == "") {
      style2.display = "none";
    } else {
      style2.display = "block";
    }
  }
}

function toggleOn(whichLayer)
{
  if (document.getElementById) {
    var style2 = document.getElementById(whichLayer).style;
    style2.display = "block";
  }
}

function toggleOff(whichLayer)
{
  if (document.getElementById) {
    var style2 = document.getElementById(whichLayer).style;
    style2.display = "none";
  }
}

function keyAlgorithmChange()
{
  var form = document.forms[0];
  var keyTypeSelect = document.forms[0].elements['keyalgorithm'];
  for (var i = 0; i < form.length; i++) {
    var name = form[i].name;
    if (name.indexOf('_keyalgorithm') != -1) {
      form.elements[name].selectedIndex = keyTypeSelect.selectedIndex;
    }
  }
}

function signingAlgorithmChange()
{
  var form = document.forms[0];
  var keyTypeSelect = document.forms[0].elements['signingalgorithm'];
  for (var i = 0; i < form.length; i++) {
    var name = form[i].name;
    if (name.indexOf('_signingalgorithm') != -1) {
      form.elements[name].selectedIndex = keyTypeSelect.selectedIndex;
    }
  }
}

function setAllAlgOptions(keyType)
{
  var form = document.forms[0];
  for (var i = 0; i < form.length; i++) {
    var name = form[i].name;
    var ind = name.indexOf('_keyalgorithm');
    if (ind != -1) {
      var tag = name.substring(0,ind);
      setAlgOptions(keyType, tag);
    }
  }
}

function setAlgOptions(keyType, certTag)
{
  var algSelect;
  var list;
  if (certTag == "commontag") {
    algSelect = document.forms[0].elements['keyalgorithm'];
  } else {
    algSelect = document.forms[0].elements[certTag + '_keyalgorithm'];
  }
  if (typeof(algSelect) == "undefined") {
    return;
  }
  algSelect.options.length=0;
  if (keyType == "rsa") {
    list = rsalist.split(",");
  } else {
    list = ecclist.split(",");
  }
  for (i=0; i < list.length; i++) {
    algSelect.options[algSelect.options.length] = new Option(list[i], list[i]);
  }
}

function setAllSigningAlgOptions(keyType)
{
  var form = document.forms[0];
  for (var i = 0; i < form.length; i++) {
    var name = form[i].name;
    var ind = name.indexOf('_signingalgorithm');
    if (ind != -1) {
      var tag = name.substring(0,ind);
      setSigningAlgOptions(keyType, tag);
    }
  }
}

function setSigningAlgOptions(keyType, certTag)
{
  var algSelect;
  var list;
  if (certTag == "commontag") {
    algSelect = document.forms[0].elements['signingalgorithm'];
  } else {
    algSelect = document.forms[0].elements[certTag + '_signingalgorithm'];
  }
  if (typeof(algSelect) == "undefined") {
    return;
  }
  algSelect.options.length=0;
  if (keyType == "rsa") {
    list = rsalist.split(",");
  } else {
    list = ecclist.split(",");
  }
  for (i=0; i < list.length; i++) {
    algSelect.options[algSelect.options.length] = new Option(list[i], list[i]);
  }
}

function toggleKeyCurve(keyType, certTag)
{
  if (keyType == "rsa") {
    toggleOn(certTag + '_custom_display_keysize');
    toggleOff(certTag + '_custom_display_curvename');
  } else {
    toggleOff(certTag + '_custom_display_keysize');
    toggleOn(certTag + '_custom_display_curvename');
  }
}

function toggleAllKeyCurves(keyType)
{
  var form = document.forms[0];
  if (keyType == "rsa") {
    toggleOn('simple_keysize');
    toggleOff('simple_curvename');
  } else {
    toggleOn('simple_curvename');
    toggleOff('simple_keysize');
  } 

  for (var i = 0; i < form.length; i++) {
    var name = form[i].name;
    var ind = name.indexOf('_keytype');
    
    if (ind != -1) {
      var tag = name.substring(0,ind);
      if (keyType =="rsa") {
          toggleOff(tag + '_custom_display_curvename');
          toggleOn(tag + '_custom_display_keysize');
      } else {
          toggleOn(tag + '_custom_display_curvename');
          toggleOff(tag + '_custom_display_keysize');
      }
    }
  }
}

function indexOfTag(tag)
{
  var index = rsaTags.indexOf(tag);
  if (index > 0) {
    if (rsaTags.charAt(index-1) != ',') {
      index = -1;
    }
  }
  return index;
}

function keyTypeChange(certTag)
{
  var form = document.forms[0];
  var keyTypeSelect;
  if (certTag == "commontag") {
    keyTypeSelect = document.forms[0].elements['keytype'];
    for (var i = 0; i < form.length; i++) {
      var name = form[i].name;
      var k = name.indexOf('_keytype');
      if (k != -1) {
        var tag = name.substring(0, k);
        if ((keyTypeSelect.value.indexOf('ecc') != -1) &&
            (indexOfTag(tag) == -1)) {
          form.elements[name].selectedIndex = keyTypeSelect.selectedIndex;
          setAlgOptions(keyTypeSelect.value, tag);
          setSigningAlgOptions(keyTypeSelect.value, tag);
          toggleKeyCurve(keyTypeSelect.value, tag);
        }
      }
    }
  } else {
      keyTypeSelect = document.forms[0].elements[certTag + '_keytype'];
      toggleKeyCurve(keyTypeSelect.value, certTag);
  }
  setAlgOptions(keyTypeSelect.value, certTag);
  setSigningAlgOptions(keyTypeSelect.value, certTag);
}

function defaultChange()
{
  var form = document.forms[0];
  var choiceSelect = document.forms[0].elements['choice'];
  for (var i = 0; i < form.length; i++) {
    var name = form[i].name;
    if (name.indexOf('_choice') != -1) {
      for (var j = 0; j < form.elements[name].length; j++) {
        var c = form.elements[name];
        c[j].checked = choiceSelect[j].checked;
      }
    }
  }
}

function customChange()
{
  var form = document.forms[0];
  var choiceSelect = document.forms[0].elements['choice'];
  for (var i = 0; i < form.length; i++) {
    var name = form[i].name;
    if (name.indexOf('_choice') != -1) {
      for (var j = 0; j < form.elements[name].length; j++) {
        var c = form.elements[name];
        c[j].checked = choiceSelect[j].checked;
      }
    }
  }
}

function textChange()
{
  var customSize = document.forms[0].elements['custom_size'];
  var form = document.forms[0];
  for (var i = 0; i < form.length; i++) {
    var name = form[i].name;
    if (name.indexOf('_custom_size') != -1) {
      form.elements[name].value = customSize.value;
    }
  }
}

function matchCurve(curve)
{
  var list = curvelist.split(",");
  for (var i=0; i < list.length; i++) {
    if (list[i] == curve) return true;
  }
  return false;
}

function curveChange()
{
  var customCurve = document.forms[0].elements['custom_curvename'];
  var check = matchCurve(customCurve.value);
  if (check == false) {
    alert("The curve name " + customCurve.value + " is not in the set of allowed curves.\n" +
          "To see a list of allowed curves, click on Details.");
    return;
  }
  var form = document.forms[0];
  for (var i = 0; i < form.length; i++) {
    var name = form[i].name;
    if (name.indexOf('_custom_curvename') != -1) {
      form.elements[name].value = customCurve.value;
    }
  }
}

function displayCurveList()
{
  var list = displaycurvelist.split(",");
  var linelen = 0;
  for (var i=0; i < list.length -1 ; i++) {
    document.write(list[i] + ",");
    linelen = linelen + list[i].length;
    if (linelen >= 60) {
      document.write("<br/>");
      linelen=0;
    }
  }
  document.write(list[list.length -1]);
}
  
</SCRIPT>
Select the key pair type(s), associated key pair size(s) or curve name(s), and signature algorithm(s) from the pulldown menus.  
<SCRIPT type="text/JavaScript">
document.write(additionalMessage);
</SCRIPT>
  <a href="javascript:toggle_details();">[Details]</a>
<SCRIPT type="text/JavaScript">
function toggle_details()
{
  d = document.getElementById('details');
  if (d.style.display == "block") {
    d.style.display="none";
  } else {
    d.style.display="block";
  }
}
</script>
<div id=details style="display: none;">
<br/>
<p>
Each certificate can have its own key pair generated with its own independent settings or common settings can be applied to all key pairs. At minimum, each key pair has to define what <i>type</i> it is by identifying a cipher family and then has to set a <i>strength</i> for that key.
</p>
<ul>
<li>
<b><i>Key Type</i></b>. Sets the cipher family to use to generate the key pair. RSA and ECC key types have slightly different strength options.
</li>
<li>
<b><i>RSA strength: Key Size</i></b>. Sets the key length for the generated pair. Longer keys are stronger, which makes them more secure. 
However, longer key pair sizes also increase the time required to perform operations such as signing certificates, so long keys can affect performance.
</li>
<li>
<b><i>ECC strength: Curve Name</i></b>. Sets the curve algorithm to use, which can be any one of the curves listed below.  The curves that are included in parenthesis are equivalent - and either name can be used.  Note that not all curves may be supported by the token.
<br/><ul style="list-style:none"><li><i>
<SCRIPT type="text/JavaScript">
displayCurveList();
</SCRIPT></i></li></ul>
</li>
<li>
<b><i>Signing Algorithm</i></b>. <i>Signing certificates only.</i> Sets the signing algorithm which will be used to sign objects issued by the subsystem. This is only displayed for certificates which are used for object signing, such as the CA signing certificate or the OCSP signing certificate.
</li>
<li><b><i>Signed With</i></b>. <i>Root CAs only.</i> Sets the signing algorithm used to sign the CA signing certificate itself.
</li>
</ul>
<br/>
</div>
#if ($select == "clone")
For a cloned subsystem, only the key for an SSL server certificate is generated.
#end
<br/>
#if ($errorString != "")
<img src="/pki/images/icon_crit_update.gif">&nbsp;<font color="red">$errorString</font>
#end
<br/>
<div id="simple">
<br/>
<table width=100%>
<tr>
  <td align=right><a href="javascript:toggleLayer1('simple'); toggleLayer('advance');" title="Advanced">[Advanced]</a></td>
</tr>
</table>
<br/>
<H2>Common Key Settings</H2>
<br/>
<table width=100% class="details">
      <tr>
        <th width="30%">Key Type:</th>
        <td><select name="keytype" onChange="keyTypeChange('commontag')"><option value="rsa">RSA</option><option value="ecc">ECC</option></select></td>
      </tr>
</table>

#if ($subsystemtype == "ca")
#if ($hselect == "root")
<table width=100% class="details">
      <tr> 
        <th width="30%">Signed With:</th>
        <td><select name="keyalgorithm" onChange="keyAlgorithmChange()">
            </select></td>
      </tr>
</table>
#end
#end

#if ($show_signing == "true")
<table width=100% class="details">
      <tr>
        <th width="30%">Signing Algorithm:</th>
        <td><select name="signingalgorithm" onChange="signingAlgorithmChange()">
            </select></td>
      </tr>
</table>
#end

<div id="simple_keysize"> 
<p>

    <input checked onChange="defaultChange()" type=radio name="choice" value="default"><b>Use the default key size ($default_keysize bits)</b>.
    <p>
    <input onChange="customChange()" type=radio name="choice" value="custom"><b>Use the following custom key size:</b>
                                                                                
    <p>
<table width=100% class="details">
      <tr>
        <th>Key Size:</th>
        <td><input onChange="textChange()" type="text" size="20" name="custom_size" value="2048" /></td>
      </tr>
</table>

</div>

<div id="simple_curvename" style="display: none;">
<p>

    <input checked onChange="defaultChange()" type=radio name="choice" value="default"><b>Use the default curve ($default_ecc_curvename)</b>.
    <p>
    <input onChange="customChange()" type=radio name="choice" value="custom"><b>Use the following curve:</b>

    <p>
<table width=100% class="details">
      <tr>
        <th width=30%>Curve Name:</th>
        <td><input onChange="curveChange()" type="text" size="20" name="custom_curvename" value="$default_ecc_curvename" /></td>
      </tr>
</table>

</div>

<!-- to be used when we can do a google-style horizontal combo-box
<div id="simple_curvename" style="display: none;">

<table width=100% class="details">
      <tr>
        <th width="30%">Curve Name:</th>
        <td><select name="custom_curvename">
                #set ($x=0)
                #foreach ($p in ${curvelist})
                    <option value="$x">$p</option>
                    #set ($x=$x+1)
                #end
            </select></td>
      </tr>
</table>
</div>
-->

</div>
<p>

<div id="advance" style="display: none;">
<p>
<table width=100%>
<tr>
  <td align=right><a href="javascript:toggleLayer1('simple');toggleLayer('advance');" title="Simple">[Simple]</a></td>
</tr>
</table>
#foreach ($item in $certs)
<H2>Key for $item.getUserFriendlyName()</H2>
<p>
<table width=100% class="details">
      <tr>
        <th width="30%">Key Type:</th>
#if ($item.isEnable())
        <td><select name="$item.getCertTag()_keytype" onChange="keyTypeChange('$item.getCertTag()')"><option value=rsa>RSA</option><option value="ecc">ECC</option></select></td>
#else
        <td><select name="$item.getCertTag()_keytype" disabled="disabled" onChange="keyTypeChange('$item.getCertTag()')"><option value=rsa>RSA</option><option value="ecc">ECC</option></select></td>
#end
      </tr>
</table>

#if ($subsystemtype == "ca")
#if ($hselect == "root")
#if ($item.getCertTag() == "signing")
<table width=100% class="details">
      <tr>
        <th width="30%">Signed With:</th>
        <td><select name="$item.getCertTag()_keyalgorithm">
            </select></td>
      </tr>
</table>
#end
#end
#end

#if ($item.isSigningRequired())
<table width=100% class="details">
      <tr>
        <th width="30%">Signing Algorithm:</th>
        <td><select name="$item.getCertTag()_signingalgorithm">
            </select></td>
      </tr>
</table>
#end

<div id="$item.getCertTag()_custom_display_keysize">
<br/>
#if ($item.isEnable())
    <input
#if ($item.useDefaultKey())
 checked
#end
 type=radio name=$item.getCertTag()_choice value="default"><b>Use the default key size ($default_keysize bits).
#else
    <input
#if ($item.useDefaultKey())
 checked
#end
 type=radio name=$item.getCertTag()_choice value="default" disabled="disabled"><b>Use the default key size ($default_keysize bits).
#end
    <br/>
#if ($item.isEnable())
    <input
#if (!$item.useDefaultKey())
 checked
#end
 type=radio name=$item.getCertTag()_choice value="custom"><b>Use the following custom key size:</b>
#else
    <input
#if (!$item.useDefaultKey())
 checked
#end
 type=radio name=$item.getCertTag()_choice value="custom" disabled="disabled"><b>Use the following custom key size:</b>
#end
                                                                                
    <br/>
<table width=100% class="details">
      <tr>
        <th>Key Size:</th>
#if ($item.isEnable())
        <td><input type="text" size="20" name=$item.getCertTag()_custom_size value=$item.getCustomKeysize() /></td>
#else
        <td><input type="text" size="20" name=$item.getCertTag()_custom_size value=$item.getCustomKeysize() disabled="disabled"/></td>
#end
      </tr>
</table>
</div>

<div id="$item.getCertTag()_custom_display_curvename" style="display: none;">
<br/>
#if ($item.isEnable())
    <input
#if ($item.useDefaultKey())
 checked
#end
 type=radio name=$item.getCertTag()_choice value="default"><b>Use the default curve ($default_ecc_curvename).
#else
    <input
#if ($item.useDefaultKey())
 checked
#end
 type=radio name=$item.getCertTag()_choice value="default" disabled="disabled"><b>Use the default curve ($default_ecc_curvename).
#end
    <br/>
#if ($item.isEnable())
    <input
#if (!$item.useDefaultKey())
 checked
#end
 type=radio name=$item.getCertTag()_choice value="custom"><b>Use the following curve:</b>
#else
    <input
#if (!$item.useDefaultKey())
 checked
#end
 type=radio name=$item.getCertTag()_choice value="custom" disabled="disabled"><b>Use the following curve:</b>
#end

    <br/>
<table width=100% class="details">
      <tr>
        <th width=30%>Curve Name:</th>
#if ($item.isEnable())
        <td><input type="text" size="20" name=$item.getCertTag()_custom_curvename value=$item.getCustomCurvename() /></td>
#else
        <td><input type="text" size="20" name=$item.getCertTag()_custom_curvename value=$item.getCustomCurvename() disabled="disabled"/></td>
#end
      </tr>
</table>
</div>

<!-- to be used when we can do a google-style combo-box
<div id="$item.getCertTag()_custom_display_curvename" style="display: none;">
<table width=100% class="details">
      <tr>
        <th width="30%">Curve Name:</th>
#if ($item.isEnable())
        <td><select name=$item.getCertTag()_custom_curvename value=$item.getCustomCurvename()>
                #set ($x=0)
                #foreach ($p in $curvelist)
                    <option value="$x">$p</option>
                    #set ($x=$x+1)
                #end
            </select>
        </td>
#else
        <td><select name=$item.getCertTag()_custom_curvename value=$item.getCustomCurvename() disabled="disabled">
                #set ($x=0)
                #foreach ($p in $curvelist)
                    <option value="$x">$p</option>
                    #set ($x=$x+1)
                #end
            </select>
        </td>
#end
      </tr>
</table>
</div>
-->

#end
</div>
<br/>
<br/>
<br/>
#if ($firsttime == 'false')
<input type="CHECKBOX" NAME="generateKeyPair">New Keys<p>
#end
<br/>
    <div align="right">
      <hr />
<i>Note: After pressing Next, keys will be generated on the server, which will take some time to complete.  Please wait for the next panel to appear.</i>
      &nbsp;
    </div>