Skip to content

Commit 7134511

Browse files
authored
Merge pull request #101 from cconlon/cursorFixes
JNI/JCE: fix warnings reported by Cursor/VSCode
2 parents 4bf623a + 3484ade commit 7134511

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+84
-356
lines changed

src/main/java/com/wolfssl/provider/jce/WolfCryptCipher.java

+3-24
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,12 @@
4545
import java.security.interfaces.RSAPrivateKey;
4646
import java.security.interfaces.RSAPublicKey;
4747

48-
import com.wolfssl.wolfcrypt.WolfCrypt;
49-
import com.wolfssl.wolfcrypt.Asn;
5048
import com.wolfssl.wolfcrypt.Aes;
5149
import com.wolfssl.wolfcrypt.AesGcm;
5250
import com.wolfssl.wolfcrypt.Des3;
5351
import com.wolfssl.wolfcrypt.Rsa;
5452
import com.wolfssl.wolfcrypt.Rng;
5553

56-
import com.wolfssl.provider.jce.WolfCryptDebug;
57-
5854
/**
5955
* wolfCrypt JCE Cipher (AES, 3DES) wrapper
6056
*/
@@ -144,6 +140,9 @@ private WolfCryptCipher(CipherType type, CipherMode mode,
144140
case WC_DES3:
145141
blockSize = Des3.BLOCK_SIZE;
146142
break;
143+
144+
case WC_RSA:
145+
break;
147146
}
148147

149148
if (WolfCryptDebug.DEBUG) {
@@ -450,8 +449,6 @@ private void wolfCryptSetIV(AlgorithmParameterSpec spec,
450449
private void wolfCryptSetKey(Key key)
451450
throws InvalidKeyException {
452451

453-
int ret = 0;
454-
long[] idx = {0};
455452
byte[] encodedKey;
456453

457454
/* validate key class type */
@@ -611,27 +608,10 @@ private boolean isBlockCipher() {
611608
return isBlockCipher;
612609
}
613610

614-
/* return 1 if cipher is a block cipher and lenth is a block
615-
* length multiple, otherwise 0 */
616-
private int isValidBlockLength(int length) {
617-
618-
/* skip if not a block cipher */
619-
if (isBlockCipher() == false) {
620-
return 1;
621-
}
622-
623-
if ((length % this.blockSize) != 0) {
624-
return 0;
625-
}
626-
627-
return 1;
628-
}
629-
630611
private byte[] wolfCryptUpdate(byte[] input, int inputOffset, int len)
631612
throws IllegalArgumentException {
632613

633614
int blocks = 0;
634-
int remaining = 0;
635615
int bytesToProcess = 0;
636616
byte[] output = null;
637617
byte[] tmpIn = null;
@@ -666,7 +646,6 @@ private byte[] wolfCryptUpdate(byte[] input, int inputOffset, int len)
666646

667647
/* calculate blocks and partial non-block size remaining */
668648
blocks = buffered.length / blockSize;
669-
remaining = buffered.length % blockSize;
670649
bytesToProcess = blocks * blockSize;
671650

672651
/* if PKCS#5/7 padding, and decrypting, hold on to last block for

src/main/java/com/wolfssl/provider/jce/WolfCryptKeyAgreement.java

-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import javax.crypto.SecretKey;
2727
import javax.crypto.ShortBufferException;
2828
import javax.crypto.spec.DHParameterSpec;
29-
import javax.crypto.SecretKey;
3029
import javax.crypto.spec.SecretKeySpec;
3130
import javax.crypto.spec.DESKeySpec;
3231
import javax.crypto.spec.DESedeKeySpec;
@@ -48,8 +47,6 @@
4847
import com.wolfssl.wolfcrypt.Dh;
4948
import com.wolfssl.wolfcrypt.Ecc;
5049

51-
import com.wolfssl.provider.jce.WolfCryptDebug;
52-
5350
/**
5451
* wolfCrypt JCE Key Agreement wrapper
5552
*/
@@ -236,9 +233,7 @@ protected byte[] engineGenerateSecret()
236233
protected int engineGenerateSecret(byte[] sharedSecret, int offset)
237234
throws IllegalStateException, ShortBufferException {
238235

239-
int ret = 0;
240236
byte tmp[] = null;
241-
long sz[] = null;
242237

243238
if (this.state != EngineState.WC_PUBKEY_DONE)
244239
throw new IllegalStateException(
@@ -355,7 +350,6 @@ protected SecretKey engineGenerateSecret(String algorithm)
355350
private void wcInitDHParams(Key key, AlgorithmParameterSpec params)
356351
throws InvalidKeyException, InvalidAlgorithmParameterException {
357352

358-
int ret = 0;
359353
byte paramP[] = null;
360354
byte paramG[] = null;
361355
byte dhPriv[] = null;
@@ -433,8 +427,6 @@ private void wcInitDHParams(Key key, AlgorithmParameterSpec params)
433427
private void getCurveFromSpec(AlgorithmParameterSpec spec)
434428
throws InvalidAlgorithmParameterException {
435429

436-
int fieldSz = 0;
437-
438430
if (spec instanceof ECGenParameterSpec) {
439431

440432
ECGenParameterSpec gs = (ECGenParameterSpec)spec;

src/main/java/com/wolfssl/provider/jce/WolfCryptKeyPairGenerator.java

-7
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,13 @@
2828
import java.security.InvalidAlgorithmParameterException;
2929

3030
import java.security.SecureRandom;
31-
import java.security.AlgorithmParameters;
3231
import java.security.spec.AlgorithmParameterSpec;
33-
import java.security.Key;
34-
import java.security.KeyPair;
3532
import java.security.KeyFactory;
36-
import java.security.NoSuchAlgorithmException;
3733
import java.security.spec.KeySpec;
3834
import java.security.spec.PKCS8EncodedKeySpec;
3935
import java.security.spec.X509EncodedKeySpec;
4036
import java.security.spec.ECGenParameterSpec;
4137
import java.security.spec.RSAKeyGenParameterSpec;
42-
import java.security.spec.InvalidKeySpecException;
4338
import java.security.interfaces.RSAPrivateKey;
4439
import java.security.interfaces.RSAPublicKey;
4540
import java.security.interfaces.ECPrivateKey;
@@ -56,8 +51,6 @@
5651
import com.wolfssl.wolfcrypt.Dh;
5752
import com.wolfssl.wolfcrypt.Rng;
5853

59-
import com.wolfssl.provider.jce.WolfCryptDebug;
60-
6154
/**
6255
* wolfCrypt JCE KeyPairGenerator wrapper class
6356
*/

src/main/java/com/wolfssl/provider/jce/WolfCryptMac.java

-6
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@
2929
import java.security.NoSuchAlgorithmException;
3030
import javax.crypto.SecretKey;
3131

32-
import com.wolfssl.wolfcrypt.WolfCrypt;
3332
import com.wolfssl.wolfcrypt.Md5;
3433
import com.wolfssl.wolfcrypt.Sha;
3534
import com.wolfssl.wolfcrypt.Sha256;
3635
import com.wolfssl.wolfcrypt.Sha384;
3736
import com.wolfssl.wolfcrypt.Sha512;
3837
import com.wolfssl.wolfcrypt.Hmac;
3938

40-
import com.wolfssl.provider.jce.WolfCryptDebug;
41-
4239
/**
4340
* wolfCrypt JCE Mac wrapper
4441
*/
@@ -53,7 +50,6 @@ enum HmacType {
5350
}
5451

5552
private Hmac hmac = null;
56-
private HmacType hmacType = null;
5753
private int nativeHmacType = 0;
5854
private int digestSize = 0;
5955

@@ -63,7 +59,6 @@ enum HmacType {
6359
private WolfCryptMac(HmacType type)
6460
throws NoSuchAlgorithmException {
6561

66-
this.hmacType = type;
6762
hmac = new Hmac();
6863

6964
switch (type) {
@@ -125,7 +120,6 @@ protected int engineGetMacLength() {
125120
protected void engineInit(Key key, AlgorithmParameterSpec params)
126121
throws InvalidKeyException, InvalidAlgorithmParameterException {
127122

128-
int ret = 0;
129123
byte[] encodedKey;
130124

131125
/* key must be of type SecretKey */

src/main/java/com/wolfssl/provider/jce/WolfCryptMessageDigestMd5.java

-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121

2222
package com.wolfssl.provider.jce;
2323

24-
import java.util.Arrays;
2524
import java.security.MessageDigestSpi;
2625
import javax.crypto.ShortBufferException;
2726

2827
import com.wolfssl.wolfcrypt.Md5;
29-
import com.wolfssl.provider.jce.WolfCryptDebug;
3028

3129
/**
3230
* wolfCrypt JCE MD5 MessageDigest wrapper

src/main/java/com/wolfssl/provider/jce/WolfCryptMessageDigestSha.java

-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121

2222
package com.wolfssl.provider.jce;
2323

24-
import java.util.Arrays;
2524
import java.security.MessageDigestSpi;
2625
import javax.crypto.ShortBufferException;
2726

2827
import com.wolfssl.wolfcrypt.Sha;
29-
import com.wolfssl.provider.jce.WolfCryptDebug;
3028

3129
/**
3230
* wolfCrypt JCE SHA-1 MessageDigest wrapper

src/main/java/com/wolfssl/provider/jce/WolfCryptMessageDigestSha256.java

-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121

2222
package com.wolfssl.provider.jce;
2323

24-
import java.util.Arrays;
2524
import java.security.MessageDigestSpi;
2625
import javax.crypto.ShortBufferException;
2726

2827
import com.wolfssl.wolfcrypt.Sha256;
29-
import com.wolfssl.provider.jce.WolfCryptDebug;
3028

3129
/**
3230
* wolfCrypt JCE SHA2-256 MessageDigest wrapper

src/main/java/com/wolfssl/provider/jce/WolfCryptMessageDigestSha384.java

-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121

2222
package com.wolfssl.provider.jce;
2323

24-
import java.util.Arrays;
2524
import java.security.MessageDigestSpi;
2625
import javax.crypto.ShortBufferException;
2726

2827
import com.wolfssl.wolfcrypt.Sha384;
29-
import com.wolfssl.provider.jce.WolfCryptDebug;
3028

3129
/**
3230
* wolfCrypt JCE SHA2-384 MessageDigest wrapper

src/main/java/com/wolfssl/provider/jce/WolfCryptMessageDigestSha512.java

-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121

2222
package com.wolfssl.provider.jce;
2323

24-
import java.util.Arrays;
2524
import java.security.MessageDigestSpi;
2625
import javax.crypto.ShortBufferException;
2726

2827
import com.wolfssl.wolfcrypt.Sha512;
29-
import com.wolfssl.provider.jce.WolfCryptDebug;
3028

3129
/**
3230
* wolfCrypt JCE SHA2-512 MessageDigest wrapper

src/main/java/com/wolfssl/provider/jce/WolfCryptPBEKey.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323

2424
import java.util.Arrays;
2525
import java.security.spec.InvalidKeySpecException;
26-
import javax.security.auth.Destroyable;
2726
import javax.crypto.interfaces.PBEKey;
2827

2928
/**
3029
* wolfCrypt PBEKey implementation.
3130
*/
32-
public class WolfCryptPBEKey implements PBEKey, Destroyable {
31+
public class WolfCryptPBEKey implements PBEKey {
3332

3433
private static final long serialVersionUID = 1L;
3534

src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java

-3
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@
4646
import java.security.cert.CRL;
4747
import java.security.cert.X509CRL;
4848
import java.security.cert.X509CRLSelector;
49-
import java.security.InvalidAlgorithmParameterException;
5049
import javax.security.auth.x500.X500Principal;
5150

5251
import com.wolfssl.wolfcrypt.Fips;
5352
import com.wolfssl.wolfcrypt.WolfCrypt;
5453
import com.wolfssl.wolfcrypt.WolfSSLCertManager;
5554
import com.wolfssl.wolfcrypt.WolfCryptException;
56-
import com.wolfssl.provider.jce.WolfCryptDebug;
5755

5856
/**
5957
* wolfJCE implementation of CertPathValidator for PKIX (X.509)
@@ -265,7 +263,6 @@ private void callCertPathCheckers(X509Certificate cert,
265263

266264
int i = 0;
267265
List<PKIXCertPathChecker> pathCheckers = null;
268-
PKIXCertPathChecker checker = null;
269266

270267
if (cert == null || params == null) {
271268
throw new CertPathValidatorException(

src/main/java/com/wolfssl/provider/jce/WolfCryptRandom.java

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.security.SecureRandomSpi;
2828

2929
import com.wolfssl.wolfcrypt.Rng;
30-
import com.wolfssl.provider.jce.WolfCryptDebug;
3130

3231
/**
3332
* wolfCrypt JCE RNG/SecureRandom wrapper

src/main/java/com/wolfssl/provider/jce/WolfCryptSecretKeyFactory.java

-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
import com.wolfssl.wolfcrypt.WolfCrypt;
3838
import com.wolfssl.wolfcrypt.Pwdbased;
39-
import com.wolfssl.provider.jce.WolfCryptDebug;
4039

4140
/**
4241
* wolfCrypt JCE SecretKeyFactory implementation.
@@ -435,12 +434,6 @@ private KeySpec getKeySpecFromPBEKeyByType(PBEKey key, Class<?> keySpec)
435434
protected synchronized KeySpec engineGetKeySpec(SecretKey key,
436435
Class<?> keySpec) throws InvalidKeySpecException {
437436

438-
PBEKey pKey = null;
439-
int iterations = 0;
440-
char[] password = null;
441-
byte[] salt = null;
442-
byte[] encoded = null;
443-
444437
log("returning KeySpec from SecretKey in requested type");
445438

446439
if (key == null) {

0 commit comments

Comments
 (0)