Skip to content

Commit

Permalink
fixed dependency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Nov 14, 2023
1 parent c413092 commit 728b725
Showing 1 changed file with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
import javax.crypto.Cipher;
import javax.crypto.SecretKey;

import org.bouncycastle.internal.asn1.cms.GCMParameters;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.jcajce.provider.symmetric.util.GcmSpecUtil;
import org.bouncycastle.jcajce.spec.AEADParameterSpec;
import org.bouncycastle.util.Arrays;

public class JceAEADCipherUtil
{
Expand All @@ -37,4 +45,43 @@ static void setUpAeadCipher(Cipher aead, SecretKey secretKey, int mode, byte[] n
aead.init(mode, secretKey, parameters);
}
}

static class GCMParameters
extends ASN1Object
{
private byte[] nonce;
private int icvLen;

public GCMParameters(
byte[] nonce,
int icvLen)
{
this.nonce = Arrays.clone(nonce);
this.icvLen = icvLen;
}

public byte[] getNonce()
{
return Arrays.clone(nonce);
}

public int getIcvLen()
{
return icvLen;
}

public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector(2);

v.add(new DEROctetString(nonce));

if (icvLen != 12)
{
v.add(new ASN1Integer(icvLen));
}

return new DERSequence(v);
}
}
}

0 comments on commit 728b725

Please sign in to comment.