def value(self): random_generator = RandomByteGenerator() key = random_generator.value(self.BLOCK_SIZE) iv = random_generator.value(self.BLOCK_SIZE) ciphertext = AES(key).encrypt(self.plaintext, mode=CBC(iv)) oracle = CBCPaddingOracle(key, iv) return CBCPaddingOracleAttack(oracle).value(ciphertext, iv)
def _init_cipher_from(self, secret, iv=None): secret_bytes = IntToBytes(secret).value() key = SHA1().hash(secret_bytes)[:self.BLOCK_SIZE] self.iv = RandomByteGenerator().value(self.BLOCK_SIZE) if iv is None\ else iv self.cipher = AES(key) self.cipher_mode = CBC(iv=self.iv)
def value(self): ciphertext = Base64Decoder().decode_file(self.FILE) return AES(self.KEY).decrypt(ciphertext, mode=CBC(self.IV)).bytes()
def __init__(self): MatasanoChallenge.__init__(self) ciphertext = Base64Decoder().decode_file(self.FILE) self.plaintext = AES(self.KEY).decrypt(ciphertext, mode=ECB()).bytes()
def value(self): key = 'YELLOW SUBMARINE' ciphertext = Base64Decoder().decode_file(self.FILE) return AES(key).decrypt(ciphertext, mode=ECB()).bytes()
def encrypt(self, plaintext): plaintext = self._prepare_plaintext(plaintext) key = self.random_generator.value(self.block_size) self.mode = self._get_random_mode() return AES(key).encrypt(plaintext, mode=self.mode)
def _encrypt(self, message): key = RandomByteGenerator().value(BlockCipherMode.DEFAULT_BLOCK_SIZE) cipher = AES(key) mode = self._get_encryption_mode() return cipher.encrypt(message, mode=mode)
def __init__(self, key, encryption_mode): self.cipher = AES(key) self.mode = encryption_mode
def __init__(self, key, iv): self.cipher = AES(key) self.iv = iv
def _encrypt(self, plaintexts): key = RandomByteGenerator().value(self.BLOCK_SIZE) aes = AES(key) return map(lambda text: aes.encrypt(text, mode=CTR(nonce=0)).bytes(), plaintexts)
def _process_chunk(self, chunk): key = self._build_key_from_register() result = AES(key).encrypt(chunk).bytes() return [self.endianness().to_int(result[:byte_size]).value()]
def __init__(self): key = RandomByteGenerator().value(self.BLOCK_SIZE) self.cipher = AES(key) self.trailing_string = self._decode_trailing_string()
def __init__(self, key): self.cipher = AES(key) self.profile_template = 'email=%s&uid=%d&role=user'
def __init__(self, key): self.cipher = AES(key)