39
39
import com .wolfssl .wolfcrypt .Asn ;
40
40
import com .wolfssl .wolfcrypt .Md5 ;
41
41
import com .wolfssl .wolfcrypt .Sha ;
42
+ import com .wolfssl .wolfcrypt .Sha224 ;
42
43
import com .wolfssl .wolfcrypt .Sha256 ;
43
44
import com .wolfssl .wolfcrypt .Sha384 ;
44
45
import com .wolfssl .wolfcrypt .Sha512 ;
@@ -60,14 +61,16 @@ enum KeyType {
60
61
enum DigestType {
61
62
WC_MD5 ,
62
63
WC_SHA1 ,
64
+ WC_SHA224 ,
63
65
WC_SHA256 ,
64
66
WC_SHA384 ,
65
67
WC_SHA512
66
68
}
67
69
68
- /* internal hash type sums */
70
+ /* internal hash type sums (asn.h) */
69
71
private int MD5h = 649 ;
70
72
private int SHAh = 88 ;
73
+ private int SHA224h = 417 ;
71
74
private int SHA256h = 414 ;
72
75
private int SHA384h = 415 ;
73
76
private int SHA512h = 416 ;
@@ -79,6 +82,7 @@ enum DigestType {
79
82
/* internal hash objects */
80
83
private Md5 md5 = null ;
81
84
private Sha sha = null ;
85
+ private Sha224 sha224 = null ;
82
86
private Sha256 sha256 = null ;
83
87
private Sha384 sha384 = null ;
84
88
private Sha512 sha512 = null ;
@@ -127,6 +131,12 @@ private WolfCryptSignature(KeyType ktype, DigestType dtype)
127
131
this .internalHashSum = SHAh ;
128
132
break ;
129
133
134
+ case WC_SHA224 :
135
+ this .sha224 = new Sha224 ();
136
+ this .digestSz = Sha224 .DIGEST_SIZE ;
137
+ this .internalHashSum = SHA224h ;
138
+ break ;
139
+
130
140
case WC_SHA256 :
131
141
this .sha256 = new Sha256 ();
132
142
this .digestSz = Sha256 .DIGEST_SIZE ;
@@ -255,6 +265,10 @@ protected synchronized void engineInitSign(PrivateKey privateKey)
255
265
this .sha .init ();
256
266
break ;
257
267
268
+ case WC_SHA224 :
269
+ this .sha224 .init ();
270
+ break ;
271
+
258
272
case WC_SHA256 :
259
273
this .sha256 .init ();
260
274
break ;
@@ -321,6 +335,10 @@ protected synchronized void engineInitVerify(PublicKey publicKey)
321
335
this .sha .init ();
322
336
break ;
323
337
338
+ case WC_SHA224 :
339
+ this .sha224 .init ();
340
+ break ;
341
+
324
342
case WC_SHA256 :
325
343
this .sha256 .init ();
326
344
break ;
@@ -366,6 +384,10 @@ protected synchronized byte[] engineSign() throws SignatureException {
366
384
this .sha .digest (digest );
367
385
break ;
368
386
387
+ case WC_SHA224 :
388
+ this .sha224 .digest (digest );
389
+ break ;
390
+
369
391
case WC_SHA256 :
370
392
this .sha256 .digest (digest );
371
393
break ;
@@ -452,6 +474,10 @@ protected synchronized void engineUpdate(byte[] b, int off, int len)
452
474
this .sha .update (b , off , len );
453
475
break ;
454
476
477
+ case WC_SHA224 :
478
+ this .sha224 .update (b , off , len );
479
+ break ;
480
+
455
481
case WC_SHA256 :
456
482
this .sha256 .update (b , off , len );
457
483
break ;
@@ -490,6 +516,10 @@ protected synchronized boolean engineVerify(byte[] sigBytes)
490
516
this .sha .digest (digest );
491
517
break ;
492
518
519
+ case WC_SHA224 :
520
+ this .sha224 .digest (digest );
521
+ break ;
522
+
493
523
case WC_SHA256 :
494
524
this .sha256 .digest (digest );
495
525
break ;
@@ -581,6 +611,8 @@ private String digestToString(DigestType type) {
581
611
return "MD5" ;
582
612
case WC_SHA1 :
583
613
return "SHA" ;
614
+ case WC_SHA224 :
615
+ return "SHA224" ;
584
616
case WC_SHA256 :
585
617
return "SHA256" ;
586
618
case WC_SHA384 :
@@ -608,6 +640,9 @@ protected synchronized void finalize() throws Throwable {
608
640
if (this .sha != null )
609
641
this .sha .releaseNativeStruct ();
610
642
643
+ if (this .sha224 != null )
644
+ this .sha224 .releaseNativeStruct ();
645
+
611
646
if (this .sha256 != null )
612
647
this .sha256 .releaseNativeStruct ();
613
648
@@ -668,6 +703,21 @@ public wcSHA1wRSA() throws NoSuchAlgorithmException {
668
703
}
669
704
}
670
705
706
+ /**
707
+ * wolfJCE SHA224wRSA signature class
708
+ */
709
+ public static final class wcSHA224wRSA extends WolfCryptSignature {
710
+ /**
711
+ * Create new wcSHA224wRSA object
712
+ *
713
+ * @throws NoSuchAlgorithmException if signature type is not
714
+ * available in native wolfCrypt library
715
+ */
716
+ public wcSHA224wRSA () throws NoSuchAlgorithmException {
717
+ super (KeyType .WC_RSA , DigestType .WC_SHA224 );
718
+ }
719
+ }
720
+
671
721
/**
672
722
* wolfJCE SHA256wRSA signature class
673
723
*/
@@ -728,6 +778,21 @@ public wcSHA1wECDSA() throws NoSuchAlgorithmException {
728
778
}
729
779
}
730
780
781
+ /**
782
+ * wolfJCE SHA224wECDSA signature class
783
+ */
784
+ public static final class wcSHA224wECDSA extends WolfCryptSignature {
785
+ /**
786
+ * Create new wcSHA224wECDSA object
787
+ *
788
+ * @throws NoSuchAlgorithmException if signature type is not
789
+ * available in native wolfCrypt library
790
+ */
791
+ public wcSHA224wECDSA () throws NoSuchAlgorithmException {
792
+ super (KeyType .WC_ECDSA , DigestType .WC_SHA224 );
793
+ }
794
+ }
795
+
731
796
/**
732
797
* wolfJCE SHA256wECDSA signature class
733
798
*/
0 commit comments