.getValidEncryptedPrivateKeyInfoEncoding("DSA");
// ... and corrupt it (set wrong alg OID length)
enc[9] = (byte) 6;
new EncryptedPrivateKeyInfo(enc);
fail(getName() + "(1): IOException has not been thrown");
} catch (IOException ok) {
}
try {
// 2: get valid encoding
enc = EncryptedPrivateKeyInfoData
.getValidEncryptedPrivateKeyInfoEncoding("DSA");
// ... and corrupt it (set wrong encrypted data tag)
enc[307] = (byte) 6;
new EncryptedPrivateKeyInfo(enc);
fail(getName() + "(2): IOException has not been thrown");
} catch (IOException ok) {
}
try {
// 3: get valid encoding
enc = EncryptedPrivateKeyInfoData
.getValidEncryptedPrivateKeyInfoEncoding("DSA");
// ... and corrupt it (set wrong encrypted data length)
enc[310] = (byte) 1;
new EncryptedPrivateKeyInfo(enc);
fail(getName() + "(3): IOException has not been thrown");
} catch (IOException ok) {
}
try {
// 4: get valid encoding
enc = EncryptedPrivateKeyInfoData
.getValidEncryptedPrivateKeyInfoEncoding("DSA");
// ... and corrupt it (set wrong tag for alg params sequence)
enc[17] = (byte) 0x29;
EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc);
if (epki.getAlgParameters() == null) {
// This kind of encoding corruption can
// be only determined while AlgorithmParameters
// initialization BUT No AlgorithmParameters instance
// available for algName0[i][0].
// So just skip this sub test
} else {
fail(getName() + "(4): IOException has not been thrown");
}
} catch (IOException ok) {
}
try {
// 5: get valid encoding
enc = EncryptedPrivateKeyInfoData
.getValidEncryptedPrivateKeyInfoEncoding("DSA");
// ... and corrupt it (set wrong length for alg params sequence)
enc[20] = (byte) 0x1d;
new EncryptedPrivateKeyInfo(enc);
fail(getName() + "(5): IOException has not been thrown");
} catch (IOException ok) {
}
try {
// 6: get valid encoding
enc = EncryptedPrivateKeyInfoData
.getValidEncryptedPrivateKeyInfoEncoding("DSA");
// ... and corrupt it (set wrong length for alg params sequence)
enc[20] = (byte) 0x1f;
new EncryptedPrivateKeyInfo(enc);
fail(getName() + "(6): IOException has not been thrown");
} catch (IOException ok) {
}
}