forked from kjur/jsrsasign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrypto-1.1.js.html
1504 lines (1504 loc) · 248 KB
/
crypto-1.1.js.html
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
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
.KEYW {color: #933;}
.COMM {color: #bbb; font-style: italic;}
.NUMB {color: #393;}
.STRN {color: #393;}
.REGX {color: #339;}
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/* crypto-1.2.3.js (c) 2013-2020 Kenji Urushima | kjur.github.io/jsrsasign/license
<span class='line'> 2</span> */</span><span class="WHIT">
<span class='line'> 3</span> </span><span class="COMM">/*
<span class='line'> 4</span> * crypto.js - Cryptographic Algorithm Provider class
<span class='line'> 5</span> *
<span class='line'> 6</span> * Copyright (c) 2013-2012 Kenji Urushima ([email protected])
<span class='line'> 7</span> *
<span class='line'> 8</span> * This software is licensed under the terms of the MIT License.
<span class='line'> 9</span> * https://kjur.github.io/jsrsasign/license
<span class='line'> 10</span> *
<span class='line'> 11</span> * The above copyright and license notice shall be
<span class='line'> 12</span> * included in all copies or substantial portions of the Software.
<span class='line'> 13</span> */</span><span class="WHIT">
<span class='line'> 14</span>
<span class='line'> 15</span> </span><span class="COMM">/**
<span class='line'> 16</span> * @fileOverview
<span class='line'> 17</span> * @name crypto-1.1.js
<span class='line'> 18</span> * @author Kenji Urushima [email protected]
<span class='line'> 19</span> * @version 1.2.3 (2020-May-28)
<span class='line'> 20</span> * @since jsrsasign 2.2
<span class='line'> 21</span> * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
<span class='line'> 22</span> */</span><span class="WHIT">
<span class='line'> 23</span>
<span class='line'> 24</span> </span><span class="COMM">/**
<span class='line'> 25</span> * kjur's class library name space
<span class='line'> 26</span> * @name KJUR
<span class='line'> 27</span> * @namespace kjur's class library name space
<span class='line'> 28</span> */</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="COMM">/**
<span class='line'> 31</span> * kjur's cryptographic algorithm provider library name space
<span class='line'> 32</span> * <p>
<span class='line'> 33</span> * This namespace privides following crytpgrahic classes.
<span class='line'> 34</span> * <ul>
<span class='line'> 35</span> * <li>{@link KJUR.crypto.MessageDigest} - Java JCE(cryptograhic extension) style MessageDigest class</li>
<span class='line'> 36</span> * <li>{@link KJUR.crypto.Signature} - Java JCE(cryptograhic extension) style Signature class</li>
<span class='line'> 37</span> * <li>{@link KJUR.crypto.Cipher} - class for encrypting and decrypting data</li>
<span class='line'> 38</span> * <li>{@link KJUR.crypto.Util} - cryptographic utility functions and properties</li>
<span class='line'> 39</span> * </ul>
<span class='line'> 40</span> * NOTE: Please ignore method summary and document of this namespace. This caused by a bug of jsdoc2.
<span class='line'> 41</span> * </p>
<span class='line'> 42</span> * @name KJUR.crypto
<span class='line'> 43</span> * @namespace
<span class='line'> 44</span> */</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR.crypto</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 46</span>
<span class='line'> 47</span> </span><span class="COMM">/**
<span class='line'> 48</span> * static object for cryptographic function utilities
<span class='line'> 49</span> * @name KJUR.crypto.Util
<span class='line'> 50</span> * @class static object for cryptographic function utilities
<span class='line'> 51</span> * @property {Array} DIGESTINFOHEAD PKCS#1 DigestInfo heading hexadecimal bytes for each hash algorithms
<span class='line'> 52</span> * @property {Array} DEFAULTPROVIDER associative array of default provider name for each hash and signature algorithms
<span class='line'> 53</span> * @description
<span class='line'> 54</span> */</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="NAME">KJUR.crypto.Util</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="NAME">this.DIGESTINFOHEAD</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="STRN">'sha1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"3021300906052b0e03021a05000414"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="STRN">'sha224'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"302d300d06096086480165030402040500041c"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT"> </span><span class="STRN">'sha256'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"3031300d060960864801650304020105000420"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="STRN">'sha384'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"3041300d060960864801650304020205000430"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="STRN">'sha512'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"3051300d060960864801650304020305000440"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="STRN">'md2'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"3020300c06082a864886f70d020205000410"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="STRN">'md5'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"3020300c06082a864886f70d020505000410"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="STRN">'ripemd160'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"3021300906052b2403020105000414"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 66</span>
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="COMM">/*
<span class='line'> 68</span> * @since crypto 1.1.1
<span class='line'> 69</span> */</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="NAME">this.DEFAULTPROVIDER</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="STRN">'md5'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="STRN">'sha1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="STRN">'sha224'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="STRN">'sha256'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="STRN">'sha384'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="STRN">'sha512'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="STRN">'ripemd160'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="STRN">'hmacmd5'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="STRN">'hmacsha1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="STRN">'hmacsha224'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="STRN">'hmacsha256'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="STRN">'hmacsha384'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="STRN">'hmacsha512'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="STRN">'hmacripemd160'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 85</span>
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="STRN">'MD5withRSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="STRN">'SHA1withRSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT"> </span><span class="STRN">'SHA224withRSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="STRN">'SHA256withRSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="STRN">'SHA384withRSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="STRN">'SHA512withRSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="STRN">'RIPEMD160withRSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 93</span>
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="STRN">'MD5withECDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="STRN">'SHA1withECDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="STRN">'SHA224withECDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="STRN">'SHA256withECDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="STRN">'SHA384withECDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT"> </span><span class="STRN">'SHA512withECDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT"> </span><span class="STRN">'RIPEMD160withECDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>101</span>
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="STRN">'SHA1withDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="STRN">'SHA224withDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT"> </span><span class="STRN">'SHA256withDSA'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>105</span>
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="STRN">'MD5withRSAandMGF1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT"> </span><span class="STRN">'SHA1withRSAandMGF1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="STRN">'SHA224withRSAandMGF1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT"> </span><span class="STRN">'SHA256withRSAandMGF1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT"> </span><span class="STRN">'SHA384withRSAandMGF1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT"> </span><span class="STRN">'SHA512withRSAandMGF1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT"> </span><span class="STRN">'RIPEMD160withRSAandMGF1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs/jsrsa'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span>
<span class='line'>115</span> </span><span class="WHIT"> </span><span class="COMM">/*
<span class='line'>116</span> * @since crypto 1.1.2
<span class='line'>117</span> */</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="NAME">this.CRYPTOJSMESSAGEDIGESTNAME</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="STRN">'md5'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">CryptoJS.algo.MD5</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="STRN">'sha1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">CryptoJS.algo.SHA1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT"> </span><span class="STRN">'sha224'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">CryptoJS.algo.SHA224</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT"> </span><span class="STRN">'sha256'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">CryptoJS.algo.SHA256</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="STRN">'sha384'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">CryptoJS.algo.SHA384</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="STRN">'sha512'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">CryptoJS.algo.SHA512</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT"> </span><span class="STRN">'ripemd160'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">CryptoJS.algo.RIPEMD160</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>127</span>
<span class='line'>128</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>129</span> * get hexadecimal DigestInfo
<span class='line'>130</span> * @name getDigestInfoHex
<span class='line'>131</span> * @memberOf KJUR.crypto.Util
<span class='line'>132</span> * @function
<span class='line'>133</span> * @param {String} hHash hexadecimal hash value
<span class='line'>134</span> * @param {String} alg hash algorithm name (ex. 'sha1')
<span class='line'>135</span> * @return {String} hexadecimal string DigestInfo ASN.1 structure
<span class='line'>136</span> */</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="NAME">this.getDigestInfoHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hHash</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">this.DIGESTINFOHEAD</span><span class="PUNC">[</span><span class="NAME">alg</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"alg not supported in Util.DIGESTINFOHEAD: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.DIGESTINFOHEAD</span><span class="PUNC">[</span><span class="NAME">alg</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hHash</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span>
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>144</span> * get PKCS#1 padded hexadecimal DigestInfo
<span class='line'>145</span> * @name getPaddedDigestInfoHex
<span class='line'>146</span> * @memberOf KJUR.crypto.Util
<span class='line'>147</span> * @function
<span class='line'>148</span> * @param {String} hHash hexadecimal hash value of message to be signed
<span class='line'>149</span> * @param {String} alg hash algorithm name (ex. 'sha1')
<span class='line'>150</span> * @param {Integer} keySize key bit length (ex. 1024)
<span class='line'>151</span> * @return {String} hexadecimal string of PKCS#1 padded DigestInfo
<span class='line'>152</span> */</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT"> </span><span class="NAME">this.getPaddedDigestInfoHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hHash</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keySize</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hDigestInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.getDigestInfoHex</span><span class="PUNC">(</span><span class="NAME">hHash</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pmStrLen</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keySize</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// minimum PM length</span><span class="WHIT">
<span class='line'>156</span>
<span class='line'>157</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hDigestInfo.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">22</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">pmStrLen</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// len(0001+ff(*8)+00+hDigestInfo)=22</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"key is too short for SigAlg: keylen="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">keySize</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">","</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>159</span>
<span class='line'>160</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hHead</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0001"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hTail</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hDigestInfo</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hMid</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fLen</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pmStrLen</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">hHead.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">hTail.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">fLen</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT"> </span><span class="NAME">hMid</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"ff"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hPaddedMessage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hHead</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hMid</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hTail</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hPaddedMessage</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span>
<span class='line'>171</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>172</span> * get hexadecimal hash of string with specified algorithm
<span class='line'>173</span> * @name hashString
<span class='line'>174</span> * @memberOf KJUR.crypto.Util
<span class='line'>175</span> * @function
<span class='line'>176</span> * @param {String} s raw input string to be hashed
<span class='line'>177</span> * @param {String} alg hash algorithm name
<span class='line'>178</span> * @return {String} hexadecimal string of hash value
<span class='line'>179</span> * @since 1.1.1
<span class='line'>180</span> */</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT"> </span><span class="NAME">this.hashString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">md</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.MessageDigest</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">md.digestString</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span>
<span class='line'>186</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>187</span> * get hexadecimal hash of hexadecimal string with specified algorithm
<span class='line'>188</span> * @name hashHex
<span class='line'>189</span> * @memberOf KJUR.crypto.Util
<span class='line'>190</span> * @function
<span class='line'>191</span> * @param {String} sHex input hexadecimal string to be hashed
<span class='line'>192</span> * @param {String} alg hash algorithm name
<span class='line'>193</span> * @return {String} hexadecimal string of hash value
<span class='line'>194</span> * @since 1.1.1
<span class='line'>195</span> */</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="NAME">this.hashHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">md</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.MessageDigest</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">md.digestHex</span><span class="PUNC">(</span><span class="NAME">sHex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span>
<span class='line'>201</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>202</span> * get hexadecimal SHA1 hash of string
<span class='line'>203</span> * @name sha1
<span class='line'>204</span> * @memberOf KJUR.crypto.Util
<span class='line'>205</span> * @function
<span class='line'>206</span> * @param {String} s raw input string to be hashed
<span class='line'>207</span> * @return {String} hexadecimal string of hash value
<span class='line'>208</span> * @since 1.0.3
<span class='line'>209</span> */</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT"> </span><span class="NAME">this.sha1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.hashString</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sha1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>213</span>
<span class='line'>214</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>215</span> * get hexadecimal SHA256 hash of string
<span class='line'>216</span> * @name sha256
<span class='line'>217</span> * @memberOf KJUR.crypto.Util
<span class='line'>218</span> * @function
<span class='line'>219</span> * @param {String} s raw input string to be hashed
<span class='line'>220</span> * @return {String} hexadecimal string of hash value
<span class='line'>221</span> * @since 1.0.3
<span class='line'>222</span> */</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT"> </span><span class="NAME">this.sha256</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.hashString</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sha256'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span>
<span class='line'>227</span> </span><span class="WHIT"> </span><span class="NAME">this.sha256Hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.hashHex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sha256'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>230</span>
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>232</span> * get hexadecimal SHA512 hash of string
<span class='line'>233</span> * @name sha512
<span class='line'>234</span> * @memberOf KJUR.crypto.Util
<span class='line'>235</span> * @function
<span class='line'>236</span> * @param {String} s raw input string to be hashed
<span class='line'>237</span> * @return {String} hexadecimal string of hash value
<span class='line'>238</span> * @since 1.0.3
<span class='line'>239</span> */</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT"> </span><span class="NAME">this.sha512</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.hashString</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sha512'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span>
<span class='line'>244</span> </span><span class="WHIT"> </span><span class="NAME">this.sha512Hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.hashHex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sha512'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>247</span>
<span class='line'>248</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>249</span> * check if key object (RSA/DSA/ECDSA) or not
<span class='line'>250</span> * @name isKey
<span class='line'>251</span> * @memberOf KJUR.crypto.Util
<span class='line'>252</span> * @function
<span class='line'>253</span> * @param {Object} obj any type argument to be checked
<span class='line'>254</span> * @return {Boolean} true if this is key object otherwise false
<span class='line'>255</span> * @since 1.0.3
<span class='line'>256</span> */</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT"> </span><span class="NAME">this.isKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">RSAKey</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.DSA</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.ECDSA</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>266</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span>
<span class='line'>268</span> </span><span class="COMM">/**
<span class='line'>269</span> * get hexadecimal MD5 hash of string
<span class='line'>270</span> * @name md5
<span class='line'>271</span> * @memberOf KJUR.crypto.Util
<span class='line'>272</span> * @function
<span class='line'>273</span> * @param {String} s input string to be hashed
<span class='line'>274</span> * @return {String} hexadecimal string of hash value
<span class='line'>275</span> * @since 1.0.3
<span class='line'>276</span> * @example
<span class='line'>277</span> * Util.md5('aaa') → 47bce5c74f589f4867dbd57e9ca9f808
<span class='line'>278</span> */</span><span class="WHIT">
<span class='line'>279</span> </span><span class="NAME">KJUR.crypto.Util.md5</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">md</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.MessageDigest</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="STRN">'md5'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'prov'</span><span class="PUNC">:</span><span class="STRN">'cryptojs'</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">md.digestString</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>282</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>283</span>
<span class='line'>284</span> </span><span class="COMM">/**
<span class='line'>285</span> * get hexadecimal RIPEMD160 hash of string
<span class='line'>286</span> * @name ripemd160
<span class='line'>287</span> * @memberOf KJUR.crypto.Util
<span class='line'>288</span> * @function
<span class='line'>289</span> * @param {String} s input string to be hashed
<span class='line'>290</span> * @return {String} hexadecimal string of hash value
<span class='line'>291</span> * @since 1.0.3
<span class='line'>292</span> * @example
<span class='line'>293</span> * KJUR.crypto.Util.ripemd160("aaa") → 08889bd7b151aa174c21f33f59147fa65381edea
<span class='line'>294</span> */</span><span class="WHIT">
<span class='line'>295</span> </span><span class="NAME">KJUR.crypto.Util.ripemd160</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">md</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.MessageDigest</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="STRN">'ripemd160'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'prov'</span><span class="PUNC">:</span><span class="STRN">'cryptojs'</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">md.digestString</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>298</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>299</span>
<span class='line'>300</span> </span><span class="COMM">// @since jsrsasign 7.0.0 crypto 1.1.11</span><span class="WHIT">
<span class='line'>301</span> </span><span class="NAME">KJUR.crypto.Util.SECURERANDOMGEN</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">SecureRandom</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>302</span>
<span class='line'>303</span> </span><span class="COMM">/**
<span class='line'>304</span> * get hexadecimal string of random value from with specified byte length<br/>
<span class='line'>305</span> * @name getRandomHexOfNbytes
<span class='line'>306</span> * @memberOf KJUR.crypto.Util
<span class='line'>307</span> * @function
<span class='line'>308</span> * @param {Integer} n length of bytes of random
<span class='line'>309</span> * @return {String} hexadecimal string of random
<span class='line'>310</span> * @since jsrsasign 7.0.0 crypto 1.1.11
<span class='line'>311</span> * @example
<span class='line'>312</span> * KJUR.crypto.Util.getRandomHexOfNbytes(3) → "6314af", "000000" or "001fb4"
<span class='line'>313</span> * KJUR.crypto.Util.getRandomHexOfNbytes(128) → "8fbc..." in 1024bits
<span class='line'>314</span> */</span><span class="WHIT">
<span class='line'>315</span> </span><span class="NAME">KJUR.crypto.Util.getRandomHexOfNbytes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ba</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>317</span> </span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.SECURERANDOMGEN.nextBytes</span><span class="PUNC">(</span><span class="NAME">ba</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">BAtohex</span><span class="PUNC">(</span><span class="NAME">ba</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>319</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>320</span>
<span class='line'>321</span> </span><span class="COMM">/**
<span class='line'>322</span> * get BigInteger object of random value from with specified byte length<br/>
<span class='line'>323</span> * @name getRandomBigIntegerOfNbytes
<span class='line'>324</span> * @memberOf KJUR.crypto.Util
<span class='line'>325</span> * @function
<span class='line'>326</span> * @param {Integer} n length of bytes of random
<span class='line'>327</span> * @return {BigInteger} BigInteger object of specified random value
<span class='line'>328</span> * @since jsrsasign 7.0.0 crypto 1.1.11
<span class='line'>329</span> * @example
<span class='line'>330</span> * KJUR.crypto.Util.getRandomBigIntegerOfNbytes(3) → 6314af of BigInteger
<span class='line'>331</span> * KJUR.crypto.Util.getRandomBigIntegerOfNbytes(128) → 8fbc... of BigInteger
<span class='line'>332</span> */</span><span class="WHIT">
<span class='line'>333</span> </span><span class="NAME">KJUR.crypto.Util.getRandomBigIntegerOfNbytes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">KJUR.crypto.Util.getRandomHexOfNbytes</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>335</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>336</span>
<span class='line'>337</span> </span><span class="COMM">/**
<span class='line'>338</span> * get hexadecimal string of random value from with specified bit length<br/>
<span class='line'>339</span> * @name getRandomHexOfNbits
<span class='line'>340</span> * @memberOf KJUR.crypto.Util
<span class='line'>341</span> * @function
<span class='line'>342</span> * @param {Integer} n length of bits of random
<span class='line'>343</span> * @return {String} hexadecimal string of random
<span class='line'>344</span> * @since jsrsasign 7.0.0 crypto 1.1.11
<span class='line'>345</span> * @example
<span class='line'>346</span> * KJUR.crypto.Util.getRandomHexOfNbits(24) → "6314af", "000000" or "001fb4"
<span class='line'>347</span> * KJUR.crypto.Util.getRandomHexOfNbits(1024) → "8fbc..." in 1024bits
<span class='line'>348</span> */</span><span class="WHIT">
<span class='line'>349</span> </span><span class="NAME">KJUR.crypto.Util.getRandomHexOfNbits</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n_remainder</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n_quotient</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">n_remainder</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ba</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">n_quotient</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.SECURERANDOMGEN.nextBytes</span><span class="PUNC">(</span><span class="NAME">ba</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT"> </span><span class="NAME">ba</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NUMB">255</span><span class="WHIT"> </span><span class="PUNC"><<</span><span class="WHIT"> </span><span class="NAME">n_remainder</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">255</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">^</span><span class="WHIT"> </span><span class="NUMB">255</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">ba</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">BAtohex</span><span class="PUNC">(</span><span class="NAME">ba</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>356</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>357</span>
<span class='line'>358</span> </span><span class="COMM">/**
<span class='line'>359</span> * get BigInteger object of random value from with specified bit length<br/>
<span class='line'>360</span> * @name getRandomBigIntegerOfNbits
<span class='line'>361</span> * @memberOf KJUR.crypto.Util
<span class='line'>362</span> * @function
<span class='line'>363</span> * @param {Integer} n length of bits of random
<span class='line'>364</span> * @return {BigInteger} BigInteger object of specified random value
<span class='line'>365</span> * @since jsrsasign 7.0.0 crypto 1.1.11
<span class='line'>366</span> * @example
<span class='line'>367</span> * KJUR.crypto.Util.getRandomBigIntegerOfNbits(24) → 6314af of BigInteger
<span class='line'>368</span> * KJUR.crypto.Util.getRandomBigIntegerOfNbits(1024) → 8fbc... of BigInteger
<span class='line'>369</span> */</span><span class="WHIT">
<span class='line'>370</span> </span><span class="NAME">KJUR.crypto.Util.getRandomBigIntegerOfNbits</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">KJUR.crypto.Util.getRandomHexOfNbits</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>372</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>373</span>
<span class='line'>374</span> </span><span class="COMM">/**
<span class='line'>375</span> * get BigInteger object of random value from zero to max value<br/>
<span class='line'>376</span> * @name getRandomBigIntegerZeroToMax
<span class='line'>377</span> * @memberOf KJUR.crypto.Util
<span class='line'>378</span> * @function
<span class='line'>379</span> * @param {BigInteger} biMax max value of BigInteger object for random value
<span class='line'>380</span> * @return {BigInteger} BigInteger object of specified random value
<span class='line'>381</span> * @since jsrsasign 7.0.0 crypto 1.1.11
<span class='line'>382</span> * @description
<span class='line'>383</span> * This static method generates a BigInteger object with random value
<span class='line'>384</span> * greater than or equal to zero and smaller than or equal to biMax
<span class='line'>385</span> * (i.e. 0 ≤ result ≤ biMax).
<span class='line'>386</span> * @example
<span class='line'>387</span> * biMax = new BigInteger("3fa411...", 16);
<span class='line'>388</span> * KJUR.crypto.Util.getRandomBigIntegerZeroToMax(biMax) → 8fbc... of BigInteger
<span class='line'>389</span> */</span><span class="WHIT">
<span class='line'>390</span> </span><span class="NAME">KJUR.crypto.Util.getRandomBigIntegerZeroToMax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">biMax</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bitLenMax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">biMax.bitLength</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biRand</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.getRandomBigIntegerOfNbits</span><span class="PUNC">(</span><span class="NAME">bitLenMax</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">biMax.compareTo</span><span class="PUNC">(</span><span class="NAME">biRand</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">biRand</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>396</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>397</span>
<span class='line'>398</span> </span><span class="COMM">/**
<span class='line'>399</span> * get BigInteger object of random value from min value to max value<br/>
<span class='line'>400</span> * @name getRandomBigIntegerMinToMax
<span class='line'>401</span> * @memberOf KJUR.crypto.Util
<span class='line'>402</span> * @function
<span class='line'>403</span> * @param {BigInteger} biMin min value of BigInteger object for random value
<span class='line'>404</span> * @param {BigInteger} biMax max value of BigInteger object for random value
<span class='line'>405</span> * @return {BigInteger} BigInteger object of specified random value
<span class='line'>406</span> * @since jsrsasign 7.0.0 crypto 1.1.11
<span class='line'>407</span> * @description
<span class='line'>408</span> * This static method generates a BigInteger object with random value
<span class='line'>409</span> * greater than or equal to biMin and smaller than or equal to biMax
<span class='line'>410</span> * (i.e. biMin ≤ result ≤ biMax).
<span class='line'>411</span> * @example
<span class='line'>412</span> * biMin = new BigInteger("2fa411...", 16);
<span class='line'>413</span> * biMax = new BigInteger("3fa411...", 16);
<span class='line'>414</span> * KJUR.crypto.Util.getRandomBigIntegerMinToMax(biMin, biMax) → 32f1... of BigInteger
<span class='line'>415</span> */</span><span class="WHIT">
<span class='line'>416</span> </span><span class="NAME">KJUR.crypto.Util.getRandomBigIntegerMinToMax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">biMin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">biMax</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">flagCompare</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">biMin.compareTo</span><span class="PUNC">(</span><span class="NAME">biMax</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flagCompare</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"biMin is greater than biMax"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flagCompare</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">biMin</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>420</span>
<span class='line'>421</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biDiff</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">biMax.subtract</span><span class="PUNC">(</span><span class="NAME">biMin</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>422</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biRand</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.getRandomBigIntegerZeroToMax</span><span class="PUNC">(</span><span class="NAME">biDiff</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">biRand.add</span><span class="PUNC">(</span><span class="NAME">biMin</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>424</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>425</span>
<span class='line'>426</span> </span><span class="COMM">// === Mac ===============================================================</span><span class="WHIT">
<span class='line'>427</span>
<span class='line'>428</span> </span><span class="COMM">/**
<span class='line'>429</span> * MessageDigest class which is very similar to java.security.MessageDigest class<br/>
<span class='line'>430</span> * @name KJUR.crypto.MessageDigest
<span class='line'>431</span> * @class MessageDigest class which is very similar to java.security.MessageDigest class
<span class='line'>432</span> * @param {Array} params parameters for constructor
<span class='line'>433</span> * @property {Array} HASHLENGTH static Array of resulted byte length of hash (ex. HASHLENGTH["sha1"] == 20)
<span class='line'>434</span> * @description
<span class='line'>435</span> * <br/>
<span class='line'>436</span> * Currently this supports following algorithm and providers combination:
<span class='line'>437</span> * <ul>
<span class='line'>438</span> * <li>md5 - cryptojs</li>
<span class='line'>439</span> * <li>sha1 - cryptojs</li>
<span class='line'>440</span> * <li>sha224 - cryptojs</li>
<span class='line'>441</span> * <li>sha256 - cryptojs</li>
<span class='line'>442</span> * <li>sha384 - cryptojs</li>
<span class='line'>443</span> * <li>sha512 - cryptojs</li>
<span class='line'>444</span> * <li>ripemd160 - cryptojs</li>
<span class='line'>445</span> * <li>sha256 - sjcl (NEW from crypto.js 1.0.4)</li>
<span class='line'>446</span> * </ul>
<span class='line'>447</span> * @example
<span class='line'>448</span> * // CryptoJS provider sample
<span class='line'>449</span> * var md = new KJUR.crypto.MessageDigest({alg: "sha1", prov: "cryptojs"});
<span class='line'>450</span> * md.updateString('aaa')
<span class='line'>451</span> * var mdHex = md.digest()
<span class='line'>452</span> *
<span class='line'>453</span> * // SJCL(Stanford JavaScript Crypto Library) provider sample
<span class='line'>454</span> * var md = new KJUR.crypto.MessageDigest({alg: "sha256", prov: "sjcl"}); // sjcl supports sha256 only
<span class='line'>455</span> * md.updateString('aaa')
<span class='line'>456</span> * var mdHex = md.digest()
<span class='line'>457</span> *
<span class='line'>458</span> * // HASHLENGTH property
<span class='line'>459</span> * KJUR.crypto.MessageDigest.HASHLENGTH['sha1'] &rarr 20
<span class='line'>460</span> * KJUR.crypto.MessageDigest.HASHLENGTH['sha512'] &rarr 64
<span class='line'>461</span> */</span><span class="WHIT">
<span class='line'>462</span> </span><span class="NAME">KJUR.crypto.MessageDigest</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">md</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>464</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">algName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>465</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">provName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>466</span>
<span class='line'>467</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>468</span> * set hash algorithm and provider<br/>
<span class='line'>469</span> * @name setAlgAndProvider
<span class='line'>470</span> * @memberOf KJUR.crypto.MessageDigest#
<span class='line'>471</span> * @function
<span class='line'>472</span> * @param {String} alg hash algorithm name
<span class='line'>473</span> * @param {String} prov provider name
<span class='line'>474</span> * @description
<span class='line'>475</span> * This methods set an algorithm and a cryptographic provider.<br/>
<span class='line'>476</span> * Here is acceptable algorithm names ignoring cases and hyphens:
<span class='line'>477</span> * <ul>
<span class='line'>478</span> * <li>MD5</li>
<span class='line'>479</span> * <li>SHA1</li>
<span class='line'>480</span> * <li>SHA224</li>
<span class='line'>481</span> * <li>SHA256</li>
<span class='line'>482</span> * <li>SHA384</li>
<span class='line'>483</span> * <li>SHA512</li>
<span class='line'>484</span> * <li>RIPEMD160</li>
<span class='line'>485</span> * </ul>
<span class='line'>486</span> * NOTE: Since jsrsasign 6.2.0 crypto 1.1.10, this method ignores
<span class='line'>487</span> * upper or lower cases. Also any hyphens (i.e. "-") will be ignored
<span class='line'>488</span> * so that "SHA1" or "SHA-1" will be acceptable.
<span class='line'>489</span> * @example
<span class='line'>490</span> * // for SHA1
<span class='line'>491</span> * md.setAlgAndProvider('sha1', 'cryptojs');
<span class='line'>492</span> * md.setAlgAndProvider('SHA1');
<span class='line'>493</span> * // for RIPEMD160
<span class='line'>494</span> * md.setAlgAndProvider('ripemd160', 'cryptojs');
<span class='line'>495</span> */</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT"> </span><span class="NAME">this.setAlgAndProvider</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prov</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.MessageDigest.getCanonicalAlgName</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>498</span>
<span class='line'>499</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">prov</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">prov</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.DEFAULTPROVIDER</span><span class="PUNC">[</span><span class="NAME">alg</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>500</span>
<span class='line'>501</span> </span><span class="WHIT"> </span><span class="COMM">// for cryptojs</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">':md5:sha1:sha224:sha256:sha384:sha512:ripemd160:'</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT"> </span><span class="NAME">prov</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>504</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT"> </span><span class="NAME">this.md</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME</span><span class="PUNC">[</span><span class="NAME">alg</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">create</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>507</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"setAlgAndProvider hash alg set fail alg="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>508</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>509</span> </span><span class="WHIT"> </span><span class="NAME">this.updateString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>510</span> </span><span class="WHIT"> </span><span class="NAME">this.md.update</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>511</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>512</span> </span><span class="WHIT"> </span><span class="NAME">this.updateHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>513</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">wHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CryptoJS.enc.Hex.parse</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>514</span> </span><span class="WHIT"> </span><span class="NAME">this.md.update</span><span class="PUNC">(</span><span class="NAME">wHex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>515</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT"> </span><span class="NAME">this.digest</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>517</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hash</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.md.finalize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hash.toString</span><span class="PUNC">(</span><span class="NAME">CryptoJS.enc.Hex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT"> </span><span class="NAME">this.digestString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT"> </span><span class="NAME">this.updateString</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.digest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>523</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>524</span> </span><span class="WHIT"> </span><span class="NAME">this.digestHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT"> </span><span class="NAME">this.updateHex</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.digest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>527</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>528</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>529</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">':sha256:'</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT"> </span><span class="NAME">prov</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'sjcl'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>531</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>532</span> </span><span class="WHIT"> </span><span class="NAME">this.md</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">sjcl.hash.sha256</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>533</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>534</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"setAlgAndProvider hash alg set fail alg="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>535</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>536</span> </span><span class="WHIT"> </span><span class="NAME">this.updateString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>537</span> </span><span class="WHIT"> </span><span class="NAME">this.md.update</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>539</span> </span><span class="WHIT"> </span><span class="NAME">this.updateHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>540</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">baHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sjcl.codec.hex.toBits</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>541</span> </span><span class="WHIT"> </span><span class="NAME">this.md.update</span><span class="PUNC">(</span><span class="NAME">baHex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>542</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>543</span> </span><span class="WHIT"> </span><span class="NAME">this.digest</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>544</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hash</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.md.finalize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>545</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sjcl.codec.hex.fromBits</span><span class="PUNC">(</span><span class="NAME">hash</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>546</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>547</span> </span><span class="WHIT"> </span><span class="NAME">this.digestString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>548</span> </span><span class="WHIT"> </span><span class="NAME">this.updateString</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>549</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.digest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>550</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>551</span> </span><span class="WHIT"> </span><span class="NAME">this.digestHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>552</span> </span><span class="WHIT"> </span><span class="NAME">this.updateHex</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>553</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.digest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>554</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>555</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>556</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>557</span>
<span class='line'>558</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>559</span> * update digest by specified string
<span class='line'>560</span> * @name updateString
<span class='line'>561</span> * @memberOf KJUR.crypto.MessageDigest#
<span class='line'>562</span> * @function
<span class='line'>563</span> * @param {String} str string to update
<span class='line'>564</span> * @description
<span class='line'>565</span> * @example
<span class='line'>566</span> * md.updateString('New York');
<span class='line'>567</span> */</span><span class="WHIT">
<span class='line'>568</span> </span><span class="WHIT"> </span><span class="NAME">this.updateString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>569</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"updateString(str) not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.provName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>570</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>571</span>
<span class='line'>572</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>573</span> * update digest by specified hexadecimal string
<span class='line'>574</span> * @name updateHex
<span class='line'>575</span> * @memberOf KJUR.crypto.MessageDigest#
<span class='line'>576</span> * @function
<span class='line'>577</span> * @param {String} hex hexadecimal string to update
<span class='line'>578</span> * @description
<span class='line'>579</span> * @example
<span class='line'>580</span> * md.updateHex('0afe36');
<span class='line'>581</span> */</span><span class="WHIT">
<span class='line'>582</span> </span><span class="WHIT"> </span><span class="NAME">this.updateHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>583</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"updateHex(hex) not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.provName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>584</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>585</span>
<span class='line'>586</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>587</span> * completes hash calculation and returns hash result
<span class='line'>588</span> * @name digest
<span class='line'>589</span> * @memberOf KJUR.crypto.MessageDigest#
<span class='line'>590</span> * @function
<span class='line'>591</span> * @description
<span class='line'>592</span> * @example
<span class='line'>593</span> * md.digest()
<span class='line'>594</span> */</span><span class="WHIT">
<span class='line'>595</span> </span><span class="WHIT"> </span><span class="NAME">this.digest</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>596</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"digest() not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.provName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>597</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>598</span>
<span class='line'>599</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>600</span> * performs final update on the digest using string, then completes the digest computation
<span class='line'>601</span> * @name digestString
<span class='line'>602</span> * @memberOf KJUR.crypto.MessageDigest#
<span class='line'>603</span> * @function
<span class='line'>604</span> * @param {String} str string to final update
<span class='line'>605</span> * @description
<span class='line'>606</span> * @example
<span class='line'>607</span> * md.digestString('aaa')
<span class='line'>608</span> */</span><span class="WHIT">
<span class='line'>609</span> </span><span class="WHIT"> </span><span class="NAME">this.digestString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>610</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"digestString(str) not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.provName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>611</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>612</span>
<span class='line'>613</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>614</span> * performs final update on the digest using hexadecimal string, then completes the digest computation
<span class='line'>615</span> * @name digestHex
<span class='line'>616</span> * @memberOf KJUR.crypto.MessageDigest#
<span class='line'>617</span> * @function
<span class='line'>618</span> * @param {String} hex hexadecimal string to final update
<span class='line'>619</span> * @description
<span class='line'>620</span> * @example
<span class='line'>621</span> * md.digestHex('0f2abd')
<span class='line'>622</span> */</span><span class="WHIT">
<span class='line'>623</span> </span><span class="WHIT"> </span><span class="NAME">this.digestHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>624</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"digestHex(hex) not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.provName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>625</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>626</span>
<span class='line'>627</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>628</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">[</span><span class="STRN">'alg'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>629</span> </span><span class="WHIT"> </span><span class="NAME">this.algName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">params</span><span class="PUNC">[</span><span class="STRN">'alg'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>630</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">[</span><span class="STRN">'prov'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>631</span> </span><span class="WHIT"> </span><span class="NAME">this.provName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.DEFAULTPROVIDER</span><span class="PUNC">[</span><span class="NAME">this.algName</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>632</span> </span><span class="WHIT"> </span><span class="NAME">this.setAlgAndProvider</span><span class="PUNC">(</span><span class="NAME">this.algName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.provName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>633</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>634</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>635</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>636</span>
<span class='line'>637</span> </span><span class="COMM">/**
<span class='line'>638</span> * get canonical hash algorithm name<br/>
<span class='line'>639</span> * @name getCanonicalAlgName
<span class='line'>640</span> * @memberOf KJUR.crypto.MessageDigest
<span class='line'>641</span> * @function
<span class='line'>642</span> * @param {String} alg hash algorithm name (ex. MD5, SHA-1, SHA1, SHA512 et.al.)
<span class='line'>643</span> * @return {String} canonical hash algorithm name
<span class='line'>644</span> * @since jsrsasign 6.2.0 crypto 1.1.10
<span class='line'>645</span> * @description
<span class='line'>646</span> * This static method normalizes from any hash algorithm name such as
<span class='line'>647</span> * "SHA-1", "SHA1", "MD5", "sha512" to lower case name without hyphens
<span class='line'>648</span> * such as "sha1".
<span class='line'>649</span> * @example
<span class='line'>650</span> * KJUR.crypto.MessageDigest.getCanonicalAlgName("SHA-1") &rarr "sha1"
<span class='line'>651</span> * KJUR.crypto.MessageDigest.getCanonicalAlgName("MD5") &rarr "md5"
<span class='line'>652</span> */</span><span class="WHIT">
<span class='line'>653</span> </span><span class="NAME">KJUR.crypto.MessageDigest.getCanonicalAlgName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>654</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>655</span> </span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">alg.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>656</span> </span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">alg.replace</span><span class="PUNC">(</span><span class="REGX">/-/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>657</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>658</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>659</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>660</span>
<span class='line'>661</span> </span><span class="COMM">/**
<span class='line'>662</span> * get resulted hash byte length for specified algorithm name<br/>
<span class='line'>663</span> * @name getHashLength
<span class='line'>664</span> * @memberOf KJUR.crypto.MessageDigest
<span class='line'>665</span> * @function
<span class='line'>666</span> * @param {String} alg non-canonicalized hash algorithm name (ex. MD5, SHA-1, SHA1, SHA512 et.al.)
<span class='line'>667</span> * @return {Integer} resulted hash byte length
<span class='line'>668</span> * @since jsrsasign 6.2.0 crypto 1.1.10
<span class='line'>669</span> * @description
<span class='line'>670</span> * This static method returns resulted byte length for specified algorithm name such as "SHA-1".
<span class='line'>671</span> * @example
<span class='line'>672</span> * KJUR.crypto.MessageDigest.getHashLength("SHA-1") &rarr 20
<span class='line'>673</span> * KJUR.crypto.MessageDigest.getHashLength("sha1") &rarr 20
<span class='line'>674</span> */</span><span class="WHIT">
<span class='line'>675</span> </span><span class="NAME">KJUR.crypto.MessageDigest.getHashLength</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>676</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">MD</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.MessageDigest</span><span class="WHIT">
<span class='line'>677</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">alg2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">MD.getCanonicalAlgName</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>678</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">MD.HASHLENGTH</span><span class="PUNC">[</span><span class="NAME">alg2</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>679</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"not supported algorithm: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>680</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">MD.HASHLENGTH</span><span class="PUNC">[</span><span class="NAME">alg2</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>681</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>682</span>
<span class='line'>683</span> </span><span class="COMM">// described in KJUR.crypto.MessageDigest class (since jsrsasign 6.2.0 crypto 1.1.10)</span><span class="WHIT">
<span class='line'>684</span> </span><span class="NAME">KJUR.crypto.MessageDigest.HASHLENGTH</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>685</span> </span><span class="WHIT"> </span><span class="STRN">'md5'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>686</span> </span><span class="WHIT"> </span><span class="STRN">'sha1'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">20</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>687</span> </span><span class="WHIT"> </span><span class="STRN">'sha224'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">28</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>688</span> </span><span class="WHIT"> </span><span class="STRN">'sha256'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>689</span> </span><span class="WHIT"> </span><span class="STRN">'sha384'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">48</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>690</span> </span><span class="WHIT"> </span><span class="STRN">'sha512'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">64</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>691</span> </span><span class="WHIT"> </span><span class="STRN">'ripemd160'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">20</span><span class="WHIT">
<span class='line'>692</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>693</span>
<span class='line'>694</span> </span><span class="COMM">// === Mac ===============================================================</span><span class="WHIT">
<span class='line'>695</span>
<span class='line'>696</span> </span><span class="COMM">/**
<span class='line'>697</span> * Mac(Message Authentication Code) class which is very similar to java.security.Mac class
<span class='line'>698</span> * @name KJUR.crypto.Mac
<span class='line'>699</span> * @class Mac class which is very similar to java.security.Mac class
<span class='line'>700</span> * @param {Array} params parameters for constructor
<span class='line'>701</span> * @description
<span class='line'>702</span> * <br/>
<span class='line'>703</span> * Currently this supports following algorithm and providers combination:
<span class='line'>704</span> * <ul>
<span class='line'>705</span> * <li>hmacmd5 - cryptojs</li>
<span class='line'>706</span> * <li>hmacsha1 - cryptojs</li>
<span class='line'>707</span> * <li>hmacsha224 - cryptojs</li>
<span class='line'>708</span> * <li>hmacsha256 - cryptojs</li>
<span class='line'>709</span> * <li>hmacsha384 - cryptojs</li>
<span class='line'>710</span> * <li>hmacsha512 - cryptojs</li>
<span class='line'>711</span> * </ul>
<span class='line'>712</span> * NOTE: HmacSHA224 and HmacSHA384 issue was fixed since jsrsasign 4.1.4.
<span class='line'>713</span> * Please use 'ext/cryptojs-312-core-fix*.js' instead of 'core.js' of original CryptoJS
<span class='line'>714</span> * to avoid those issue.
<span class='line'>715</span> * <br/>
<span class='line'>716</span> * NOTE2: Hmac signature bug was fixed in jsrsasign 4.9.0 by providing CryptoJS
<span class='line'>717</span> * bug workaround.
<span class='line'>718</span> * <br/>
<span class='line'>719</span> * Please see {@link KJUR.crypto.Mac.setPassword}, how to provide password
<span class='line'>720</span> * in various ways in detail.
<span class='line'>721</span> * @example
<span class='line'>722</span> * var mac = new KJUR.crypto.Mac({alg: "HmacSHA1", "pass": "pass"});
<span class='line'>723</span> * mac.updateString('aaa')
<span class='line'>724</span> * var macHex = mac.doFinal()
<span class='line'>725</span> *
<span class='line'>726</span> * // other password representation
<span class='line'>727</span> * var mac = new KJUR.crypto.Mac({alg: "HmacSHA256", "pass": {"hex": "6161"}});
<span class='line'>728</span> * var mac = new KJUR.crypto.Mac({alg: "HmacSHA256", "pass": {"utf8": "aa"}});
<span class='line'>729</span> * var mac = new KJUR.crypto.Mac({alg: "HmacSHA256", "pass": {"rstr": "\x61\x61"}});
<span class='line'>730</span> * var mac = new KJUR.crypto.Mac({alg: "HmacSHA256", "pass": {"b64": "Mi02/+...a=="}});
<span class='line'>731</span> * var mac = new KJUR.crypto.Mac({alg: "HmacSHA256", "pass": {"b64u": "Mi02_-...a"}});
<span class='line'>732</span> */</span><span class="WHIT">
<span class='line'>733</span> </span><span class="NAME">KJUR.crypto.Mac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>734</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>735</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>736</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">algName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>737</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">provName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>738</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">algProv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>739</span>
<span class='line'>740</span> </span><span class="WHIT"> </span><span class="NAME">this.setAlgAndProvider</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prov</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>741</span> </span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">alg.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>742</span>
<span class='line'>743</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"hmacsha1"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>744</span>
<span class='line'>745</span> </span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">alg.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>746</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">alg.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"hmac"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>747</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"setAlgAndProvider unsupported HMAC alg: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>748</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>749</span>
<span class='line'>750</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">prov</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">prov</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.DEFAULTPROVIDER</span><span class="PUNC">[</span><span class="NAME">alg</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>751</span> </span><span class="WHIT"> </span><span class="NAME">this.algProv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">prov</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>752</span>
<span class='line'>753</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hashAlg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">alg.substr</span><span class="PUNC">(</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>754</span>
<span class='line'>755</span> </span><span class="WHIT"> </span><span class="COMM">// for cryptojs</span><span class="WHIT">
<span class='line'>756</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">':md5:sha1:sha224:sha256:sha384:sha512:ripemd160:'</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">hashAlg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>757</span> </span><span class="WHIT"> </span><span class="NAME">prov</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>758</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>759</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mdObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME</span><span class="PUNC">[</span><span class="NAME">hashAlg</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>760</span> </span><span class="WHIT"> </span><span class="NAME">this.mac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CryptoJS.algo.HMAC.create</span><span class="PUNC">(</span><span class="NAME">mdObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.pass</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>761</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>762</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"setAlgAndProvider hash alg set fail hashAlg="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hashAlg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>763</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>764</span> </span><span class="WHIT"> </span><span class="NAME">this.updateString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>765</span> </span><span class="WHIT"> </span><span class="NAME">this.mac.update</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>766</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>767</span> </span><span class="WHIT"> </span><span class="NAME">this.updateHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>768</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">wHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CryptoJS.enc.Hex.parse</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>769</span> </span><span class="WHIT"> </span><span class="NAME">this.mac.update</span><span class="PUNC">(</span><span class="NAME">wHex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>771</span> </span><span class="WHIT"> </span><span class="NAME">this.doFinal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>772</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hash</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.mac.finalize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>773</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hash.toString</span><span class="PUNC">(</span><span class="NAME">CryptoJS.enc.Hex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>774</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>775</span> </span><span class="WHIT"> </span><span class="NAME">this.doFinalString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>776</span> </span><span class="WHIT"> </span><span class="NAME">this.updateString</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.doFinal</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>779</span> </span><span class="WHIT"> </span><span class="NAME">this.doFinalHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>780</span> </span><span class="WHIT"> </span><span class="NAME">this.updateHex</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>781</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.doFinal</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>782</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>783</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>784</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>785</span>
<span class='line'>786</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>787</span> * update digest by specified string
<span class='line'>788</span> * @name updateString
<span class='line'>789</span> * @memberOf KJUR.crypto.Mac#
<span class='line'>790</span> * @function
<span class='line'>791</span> * @param {String} str string to update
<span class='line'>792</span> * @description
<span class='line'>793</span> * @example
<span class='line'>794</span> * mac.updateString('New York');
<span class='line'>795</span> */</span><span class="WHIT">
<span class='line'>796</span> </span><span class="WHIT"> </span><span class="NAME">this.updateString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>797</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"updateString(str) not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algProv</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>798</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>799</span>
<span class='line'>800</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>801</span> * update digest by specified hexadecimal string
<span class='line'>802</span> * @name updateHex
<span class='line'>803</span> * @memberOf KJUR.crypto.Mac#
<span class='line'>804</span> * @function
<span class='line'>805</span> * @param {String} hex hexadecimal string to update
<span class='line'>806</span> * @description
<span class='line'>807</span> * @example
<span class='line'>808</span> * mac.updateHex('0afe36');
<span class='line'>809</span> */</span><span class="WHIT">
<span class='line'>810</span> </span><span class="WHIT"> </span><span class="NAME">this.updateHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>811</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"updateHex(hex) not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algProv</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>812</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>813</span>
<span class='line'>814</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>815</span> * completes hash calculation and returns hash result
<span class='line'>816</span> * @name doFinal
<span class='line'>817</span> * @memberOf KJUR.crypto.Mac#
<span class='line'>818</span> * @function
<span class='line'>819</span> * @description
<span class='line'>820</span> * @example
<span class='line'>821</span> * mac.digest()
<span class='line'>822</span> */</span><span class="WHIT">
<span class='line'>823</span> </span><span class="WHIT"> </span><span class="NAME">this.doFinal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>824</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"digest() not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algProv</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>825</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>826</span>
<span class='line'>827</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>828</span> * performs final update on the digest using string, then completes the digest computation
<span class='line'>829</span> * @name doFinalString
<span class='line'>830</span> * @memberOf KJUR.crypto.Mac#
<span class='line'>831</span> * @function
<span class='line'>832</span> * @param {String} str string to final update
<span class='line'>833</span> * @description
<span class='line'>834</span> * @example
<span class='line'>835</span> * mac.digestString('aaa')
<span class='line'>836</span> */</span><span class="WHIT">
<span class='line'>837</span> </span><span class="WHIT"> </span><span class="NAME">this.doFinalString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>838</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"digestString(str) not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algProv</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>839</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>840</span>
<span class='line'>841</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>842</span> * performs final update on the digest using hexadecimal string,
<span class='line'>843</span> * then completes the digest computation
<span class='line'>844</span> * @name doFinalHex
<span class='line'>845</span> * @memberOf KJUR.crypto.Mac#
<span class='line'>846</span> * @function
<span class='line'>847</span> * @param {String} hex hexadecimal string to final update
<span class='line'>848</span> * @description
<span class='line'>849</span> * @example
<span class='line'>850</span> * mac.digestHex('0f2abd')
<span class='line'>851</span> */</span><span class="WHIT">
<span class='line'>852</span> </span><span class="WHIT"> </span><span class="NAME">this.doFinalHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>853</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"digestHex(hex) not supported for this alg/prov: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.algProv</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>854</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>855</span>
<span class='line'>856</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>857</span> * set password for Mac
<span class='line'>858</span> * @name setPassword
<span class='line'>859</span> * @memberOf KJUR.crypto.Mac#
<span class='line'>860</span> * @function
<span class='line'>861</span> * @param {Object} pass password for Mac
<span class='line'>862</span> * @since crypto 1.1.7 jsrsasign 4.9.0
<span class='line'>863</span> * @description
<span class='line'>864</span> * This method will set password for (H)Mac internally.
<span class='line'>865</span> * Argument 'pass' can be specified as following:
<span class='line'>866</span> * <ul>
<span class='line'>867</span> * <li>even length string of 0..9, a..f or A-F: implicitly specified as hexadecimal string</li>
<span class='line'>868</span> * <li>not above string: implicitly specified as raw string</li>
<span class='line'>869</span> * <li>{rstr: "\x65\x70"}: explicitly specified as raw string</li>
<span class='line'>870</span> * <li>{hex: "6570"}: explicitly specified as hexacedimal string</li>
<span class='line'>871</span> * <li>{utf8: "秘密"}: explicitly specified as UTF8 string</li>
<span class='line'>872</span> * <li>{b64: "Mi78..=="}: explicitly specified as Base64 string</li>
<span class='line'>873</span> * <li>{b64u: "Mi7-_"}: explicitly specified as Base64URL string</li>
<span class='line'>874</span> * </ul>
<span class='line'>875</span> * It is *STRONGLY RECOMMENDED* that explicit representation of password argument
<span class='line'>876</span> * to avoid ambiguity. For example string "6161" can mean a string "6161" or
<span class='line'>877</span> * a hexadecimal string of "aa" (i.e. \x61\x61).
<span class='line'>878</span> * @example
<span class='line'>879</span> * mac = KJUR.crypto.Mac({'alg': 'hmacsha256'});
<span class='line'>880</span> * // set password by implicit raw string
<span class='line'>881</span> * mac.setPassword("\x65\x70\xb9\x0b");
<span class='line'>882</span> * mac.setPassword("password");
<span class='line'>883</span> * // set password by implicit hexadecimal string
<span class='line'>884</span> * mac.setPassword("6570b90b");
<span class='line'>885</span> * mac.setPassword("6570B90B");
<span class='line'>886</span> * // set password by explicit raw string
<span class='line'>887</span> * mac.setPassword({"rstr": "\x65\x70\xb9\x0b"});
<span class='line'>888</span> * // set password by explicit hexadecimal string
<span class='line'>889</span> * mac.setPassword({"hex": "6570b90b"});
<span class='line'>890</span> * // set password by explicit utf8 string
<span class='line'>891</span> * mac.setPassword({"utf8": "passwordパスワード");
<span class='line'>892</span> * // set password by explicit Base64 string
<span class='line'>893</span> * mac.setPassword({"b64": "Mb+c3f/=="});
<span class='line'>894</span> * // set password by explicit Base64URL string
<span class='line'>895</span> * mac.setPassword({"b64u": "Mb-c3f_"});
<span class='line'>896</span> */</span><span class="WHIT">
<span class='line'>897</span> </span><span class="WHIT"> </span><span class="NAME">this.setPassword</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">pass</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>898</span> </span><span class="WHIT"> </span><span class="COMM">// internal this.pass shall be CryptoJS DWord Object for CryptoJS bug</span><span class="WHIT">
<span class='line'>899</span> </span><span class="WHIT"> </span><span class="COMM">// work around. CrytoJS HMac password can be passed by</span><span class="WHIT">
<span class='line'>900</span> </span><span class="WHIT"> </span><span class="COMM">// raw string as described in the manual however it doesn't</span><span class="WHIT">
<span class='line'>901</span> </span><span class="WHIT"> </span><span class="COMM">// work properly in some case. If password was passed</span><span class="WHIT">
<span class='line'>902</span> </span><span class="WHIT"> </span><span class="COMM">// by CryptoJS DWord which is not described in the manual</span><span class="WHIT">
<span class='line'>903</span> </span><span class="WHIT"> </span><span class="COMM">// it seems to work. (fixed since crypto 1.1.7)</span><span class="WHIT">
<span class='line'>904</span>
<span class='line'>905</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">pass</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>906</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hPass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pass</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>907</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pass.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">pass.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9A-Fa-f]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// raw str</span><span class="WHIT">
<span class='line'>908</span> </span><span class="WHIT"> </span><span class="NAME">hPass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rstrtohex</span><span class="PUNC">(</span><span class="NAME">pass</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>909</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>910</span> </span><span class="WHIT"> </span><span class="NAME">this.pass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CryptoJS.enc.Hex.parse</span><span class="PUNC">(</span><span class="NAME">hPass</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>911</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>912</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>913</span>
<span class='line'>914</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">pass</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>915</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"KJUR.crypto.Mac unsupported password type: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pass</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>916</span> </span><span class="WHIT">
<span class='line'>917</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hPass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>918</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pass.hex</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>919</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pass.hex.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">pass.hex.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9A-Fa-f]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>920</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Mac: wrong hex password: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pass.hex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>921</span> </span><span class="WHIT"> </span><span class="NAME">hPass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pass.hex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>922</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>923</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pass.utf8</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hPass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">utf8tohex</span><span class="PUNC">(</span><span class="NAME">pass.utf8</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>924</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pass.rstr</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hPass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rstrtohex</span><span class="PUNC">(</span><span class="NAME">pass.rstr</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>925</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pass.b64</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hPass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64tohex</span><span class="PUNC">(</span><span class="NAME">pass.b64</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>926</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pass.b64u</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hPass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utohex</span><span class="PUNC">(</span><span class="NAME">pass.b64u</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>927</span>
<span class='line'>928</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hPass</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>929</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"KJUR.crypto.Mac unsupported password type: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pass</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>930</span>
<span class='line'>931</span> </span><span class="WHIT"> </span><span class="NAME">this.pass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CryptoJS.enc.Hex.parse</span><span class="PUNC">(</span><span class="NAME">hPass</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>932</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>933</span>
<span class='line'>934</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>935</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params.pass</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>936</span> </span><span class="WHIT"> </span><span class="NAME">this.setPassword</span><span class="PUNC">(</span><span class="NAME">params.pass</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>937</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>938</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params.alg</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>939</span> </span><span class="WHIT"> </span><span class="NAME">this.algName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">params.alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>940</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">[</span><span class="STRN">'prov'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>941</span> </span><span class="WHIT"> </span><span class="NAME">this.provName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.DEFAULTPROVIDER</span><span class="PUNC">[</span><span class="NAME">this.algName</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>942</span> </span><span class="WHIT"> </span><span class="NAME">this.setAlgAndProvider</span><span class="PUNC">(</span><span class="NAME">this.algName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.provName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>943</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>944</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>945</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>946</span>
<span class='line'>947</span> </span><span class="COMM">// ====== Signature class =========================================================</span><span class="WHIT">
<span class='line'>948</span> </span><span class="COMM">/**
<span class='line'>949</span> * Signature class which is very similar to java.security.Signature class
<span class='line'>950</span> * @name KJUR.crypto.Signature
<span class='line'>951</span> * @class Signature class which is very similar to java.security.Signature class
<span class='line'>952</span> * @param {Array} params parameters for constructor
<span class='line'>953</span> * @property {String} state Current state of this signature object whether 'SIGN', 'VERIFY' or null
<span class='line'>954</span> * @description
<span class='line'>955</span> * <br/>
<span class='line'>956</span> * As for params of constructor's argument, it can be specify following attributes:
<span class='line'>957</span> * <ul>
<span class='line'>958</span> * <li>alg - signature algorithm name (ex. {MD5,SHA1,SHA224,SHA256,SHA384,SHA512,RIPEMD160}with{RSA,ECDSA,DSA})</li>
<span class='line'>959</span> * <li>provider - currently 'cryptojs/jsrsa' only</li>
<span class='line'>960</span> * </ul>
<span class='line'>961</span> * <h4>SUPPORTED ALGORITHMS AND PROVIDERS</h4>
<span class='line'>962</span> * This Signature class supports following signature algorithm and provider names:
<span class='line'>963</span> * <ul>
<span class='line'>964</span> * <li>MD5withRSA - cryptojs/jsrsa</li>
<span class='line'>965</span> * <li>SHA1withRSA - cryptojs/jsrsa</li>
<span class='line'>966</span> * <li>SHA224withRSA - cryptojs/jsrsa</li>
<span class='line'>967</span> * <li>SHA256withRSA - cryptojs/jsrsa</li>
<span class='line'>968</span> * <li>SHA384withRSA - cryptojs/jsrsa</li>
<span class='line'>969</span> * <li>SHA512withRSA - cryptojs/jsrsa</li>
<span class='line'>970</span> * <li>RIPEMD160withRSA - cryptojs/jsrsa</li>
<span class='line'>971</span> * <li>MD5withECDSA - cryptojs/jsrsa</li>
<span class='line'>972</span> * <li>SHA1withECDSA - cryptojs/jsrsa</li>
<span class='line'>973</span> * <li>SHA224withECDSA - cryptojs/jsrsa</li>
<span class='line'>974</span> * <li>SHA256withECDSA - cryptojs/jsrsa</li>
<span class='line'>975</span> * <li>SHA384withECDSA - cryptojs/jsrsa</li>
<span class='line'>976</span> * <li>SHA512withECDSA - cryptojs/jsrsa</li>
<span class='line'>977</span> * <li>RIPEMD160withECDSA - cryptojs/jsrsa</li>
<span class='line'>978</span> * <li>MD5withRSAandMGF1 - cryptojs/jsrsa</li>
<span class='line'>979</span> * <li>SHA1withRSAandMGF1 - cryptojs/jsrsa</li>
<span class='line'>980</span> * <li>SHA224withRSAandMGF1 - cryptojs/jsrsa</li>
<span class='line'>981</span> * <li>SHA256withRSAandMGF1 - cryptojs/jsrsa</li>
<span class='line'>982</span> * <li>SHA384withRSAandMGF1 - cryptojs/jsrsa</li>
<span class='line'>983</span> * <li>SHA512withRSAandMGF1 - cryptojs/jsrsa</li>
<span class='line'>984</span> * <li>RIPEMD160withRSAandMGF1 - cryptojs/jsrsa</li>
<span class='line'>985</span> * <li>SHA1withDSA - cryptojs/jsrsa</li>
<span class='line'>986</span> * <li>SHA224withDSA - cryptojs/jsrsa</li>
<span class='line'>987</span> * <li>SHA256withDSA - cryptojs/jsrsa</li>
<span class='line'>988</span> * </ul>
<span class='line'>989</span> * Here are supported elliptic cryptographic curve names and their aliases for ECDSA:
<span class='line'>990</span> * <ul>
<span class='line'>991</span> * <li>secp256k1</li>
<span class='line'>992</span> * <li>secp256r1, NIST P-256, P-256, prime256v1</li>
<span class='line'>993</span> * <li>secp384r1, NIST P-384, P-384</li>