status_t AESAlgorithm::Init(ThreadContext& context) { // Make space for our key schedule buffer fEncryptScheduler = context.AddBuffer(sizeof(aes_encrypt_ctx)); fDecryptScheduler = context.AddBuffer(sizeof(aes_decrypt_ctx)); if (fEncryptScheduler < 0 || fDecryptScheduler < 0) return B_NO_MEMORY; return B_OK; }
status_t LRWMode::Init(ThreadContext& context, EncryptionAlgorithm* algorithm) { if (algorithm == NULL) return B_BAD_VALUE; fGaloisField = context.AddBuffer(sizeof(struct galois_field_context)); if (fGaloisField < 0) return B_NO_MEMORY; fAlgorithm = algorithm; fAlgorithm->SetMode(this); return B_OK; }