uni.BouncyCastle-JCA.3.1.1.source-code.Cipher.crysl Maven / Gradle / Ivy
SPEC javax.crypto.Cipher
OBJECTS
java.lang.String transformation;
int encmode;
java.security.Key key;
java.security.cert.Certificate certificate;
java.security.spec.AlgorithmParameterSpec paramSpec;
java.security.AlgorithmParameters params;
int prePlainTextOffset;
int preCipherTextOffset;
int plainTextOffset;
int cipherTextOffset;
int aadOffset;
int prePlainTextLen;
int plainTextLen;
int aadLen;
byte[] prePlainText;
byte[] preCipherText;
java.nio.ByteBuffer prePlainTextByteBuffer;
java.nio.ByteBuffer preCipherTextByteBuffer;
byte[] plainText;
byte[] cipherText;
byte[] wrappedKeyBytes;
java.nio.ByteBuffer plainTextByteBuffer;
java.nio.ByteBuffer cipherTextByteBuffer;
byte[] aadBytes;
java.nio.ByteBuffer aadByteBuffer;
java.security.SecureRandom random;
java.security.Key wrappedKey;
EVENTS
g1: getInstance(transformation);
g2: getInstance(transformation, _);
Get := g1 | g2;
i1: init(encmode, certificate);
i2: init(encmode, certificate, random);
i3: init(encmode, key);
i4: init(encmode, key, paramSpec);
i5: init(encmode, key, params);
i6: init(encmode, key, paramSpec, random);
i7: init(encmode, key, params, random);
i8: init(encmode, key, random);
IWOIV := i1 | i2 | i3 | i8;
IWIV := i4 | i5 | i6 | i7;
Init := IWOIV | IWIV;
u1: preCipherText = update(prePlainText);
u2: preCipherText = update(prePlainText, prePlainTextOffset, prePlainTextLen);
u3: update(prePlainText, prePlainTextOffset, prePlainTextLen, preCipherText);
u4: update(prePlainText, prePlainTextOffset, prePlainTextLen, preCipherText, preCipherTextOffset);
u5: update(prePlainTextByteBuffer, preCipherTextByteBuffer);
Update := u1 | u2 | u3 | u4 | u5;
ua1: updateAAD(aadBytes);
ua2: updateAAD(aadBytes, aadOffset, aadLen);
ua3: updateAAD(aadByteBuffer);
AADUpdate := ua1 | ua2 | ua3;
f1: cipherText = doFinal();
f2: cipherText = doFinal(plainText);
f3: doFinal(cipherText, cipherTextOffset);
f4: cipherText = doFinal(plainText, plainTextOffset, plainTextLen);
f5: doFinal(plainText, plainTextOffset, plainTextLen, cipherText);
f6: doFinal(plainText, plainTextOffset, plainTextLen, cipherText, cipherTextOffset);
f7: doFinal(plainTextByteBuffer, cipherTextByteBuffer);
FINWOU := f2 | f4 | f5 | f6 | f7;
DoFinal := FINWOU | f1 | f3;
wkb1: wrappedKeyBytes = wrap(wrappedKey);
WKB := wkb1;
iv1: getIV();
IV := iv1;
ORDER
Get, Init+, AADUpdate*, WKB+ | (FINWOU | (Update+, DoFinal))+
CONSTRAINTS
instanceOf[key, java.security.PublicKey] || instanceOf[key, java.security.PrivateKey] || encmode in {3, 4} => alg(transformation) in {"RSA"};
instanceOf[key, javax.crypto.SecretKey] => alg(transformation) in {"AES", "RIJNDAEL", "ElGamal",
"Twofish", "Camellia", "Serpent", "Tnepres", "Shacal2", "Shacal-2", "McEliece",
"McEliecePointcheval", "McElieceKobaraImai", "McElieceFujisaki"};
noCallTo[Init] => alg(transformation) in {"AES", "RSA", "RIJNDAEL", "ElGamal", "Twofish", "Camellia",
"Serpent", "Tnepres", "Shacal2", "Shacal-2", "McEliece", "McEliecePointcheval", "McElieceKobaraImai",
"McElieceFujisaki"};
alg(transformation) in {"AES"} => mode(transformation) in { "GCM", "CTR", "CTS", "CFB", "OFB", "CCM"};
alg(transformation) in {"RIJNDAEL"} => mode(transformation) in { "GCM", "CTR", "CTS", "CFB", "OFB", "CCM"};
alg(transformation) in {"ElGamal"} => mode(transformation) in {"ECB"};
alg(transformation) in {"Serpent"} => mode(transformation) in { "CFB", "OFB"};
alg(transformation) in {"Tnepres"} => mode(transformation) in {"CFB", "OFB"};
alg(transformation) in {"ElGamal"} && mode(transformation) in {"ECB"} => pad(transformation) in {"PKCS1Padding"};
alg(transformation) in {"RSA"} && mode(transformation) in {""} => pad(transformation) in {""};
alg(transformation) in {"RSA"} && mode(transformation) in {"ECB"} => pad(transformation) in {"PKCS1Padding","OAEPWithMD5AndMGF1Padding",
"OAEPWithSHA-224AndMGF1Padding", "OAEPWithSHA-256AndMGF1Padding",
"OAEPWithSHA-384AndMGF1Padding", "OAEPWithSHA-512AndMGF1Padding"};
alg(transformation) in {"AES"} && mode(transformation) in {"GCM", "CTR", "CTS", "CFB", "OFB", "CCM"} => pad(transformation) in {"NoPadding"};
alg(transformation) in {"RIJNDAEL"} && mode(transformation) in {"GCM", "CTR", "CTS", "CFB", "OFB", "CCM"} => pad(transformation) in {"NoPadding"};
alg(transformation) in {"Serpent"} && mode(transformation) in {"CFB", "OFB"} => pad(transformation) in {"NoPadding"};
alg(transformation) in {"Tnepres"} && mode(transformation) in {"CFB", "OFB"} => pad(transformation) in {"NoPadding"};
mode(transformation) in { "CTR", "CTS", "CFB", "OFB", "CCM"} && encmode != 1 => noCallTo[IWOIV];
mode(transformation) in {"CTR", "CTS", "CFB", "OFB", "CCM"} && encmode == 1 => callTo[IV];
mode(transformation) in {"CTR", "CTS", "CFB", "ECB", "OFB"} => noCallTo[AADUpdate];
encmode in {1,2,3,4};
length[prePlainText] >= prePlainTextOffset + prePlainTextLen;
length[preCipherText] >= preCipherTextOffset;
prePlainTextOffset >= 0;
prePlainTextLen > 0;
preCipherTextOffset >= 0;
length[plainText] >= plainTextOffset + plainTextLen;
length[cipherText] >= cipherTextOffset;
plainTextOffset >= 0;
plainTextLen > 0;
cipherTextOffset >= 0;
REQUIRES
generatedKey[key, alg(transformation)] || generatedPubkey[key] || generatedPrivkey[key];
randomized[random];
preparedAlg[params, alg(transformation)];
!macced[this, plainText];
mode(transformation) in {"CTR", "CTS", "CFB", "OFB"} && encmode == 1 => preparedIV[paramSpec];
mode(transformation) in {"GCM"} => preparedGCM[paramSpec];
mode(transformation) in {"OAEPWithMD5AndMGF1Padding", "OAEPWithSHA-224AndMGF1Padding", "OAEPWithSHA-256AndMGF1Padding",
"OAEPWithSHA-384AndMGF1Padding", "OAEPWithSHA-512AndMGF1Padding"} => preparedOAEP[paramSpec];
ENSURES
generatedCipher[this] after Init;
encrypted[preCipherText, prePlainText] after Update;
encrypted[cipherText, plainText];
encrypted[cipherTextByteBuffer, plainTextByteBuffer];
wrappedKey[wrappedKeyBytes, wrappedKey];
© 2015 - 2025 Weber Informatics LLC | Privacy Policy