summaryrefslogtreecommitdiff
path: root/ocb_utils.h
diff options
context:
space:
mode:
authorShawn Willden <swillden@google.com>2015-05-26 08:31:37 -0600
committerShawn Willden <swillden@google.com>2015-05-26 10:21:38 -0600
commit0cb6942d3efb6c056f96321c82a4b3d86af601d6 (patch)
treecd34b5b3afdce65e41c47436944048cec90db97d /ocb_utils.h
parent13fbe3e93247943c26e7ca2ed27b6d650282b8bf (diff)
downloadkeymaster-0cb6942d3efb6c056f96321c82a4b3d86af601d6.tar.gz
Revert "Revert "Large refactor to move context out of AndroidKeymaster.""
This reverts commit 13fbe3e93247943c26e7ca2ed27b6d650282b8bf. Bug: 20912868, 19799085 Change-Id: Iadd6ce5cbe94956c2a2fe277f1bf5b108e4bcf57
Diffstat (limited to 'ocb_utils.h')
-rw-r--r--ocb_utils.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/ocb_utils.h b/ocb_utils.h
index 2104742..bae1e08 100644
--- a/ocb_utils.h
+++ b/ocb_utils.h
@@ -19,21 +19,29 @@
#include "ae.h"
+#include <hardware/keymaster_defs.h>
+
+#include <keymaster/serializable.h>
+
namespace keymaster {
-class AeCtx {
- public:
- AeCtx() : ctx_(ae_allocate(NULL)) {}
- ~AeCtx() {
- ae_clear(ctx_);
- ae_free(ctx_);
- }
+class AuthorizationSet;
+struct KeymasterKeyBlob;
+
+static const int OCB_NONCE_LENGTH = 12;
+static const int OCB_TAG_LENGTH = 16;
- ae_ctx* get() { return ctx_; }
+keymaster_error_t OcbEncryptKey(const AuthorizationSet& hw_enforced,
+ const AuthorizationSet& sw_enforced, const AuthorizationSet& hidden,
+ const KeymasterKeyBlob& master_key,
+ const KeymasterKeyBlob& plaintext, const Buffer& nonce,
+ KeymasterKeyBlob* ciphertext, Buffer* tag);
- private:
- ae_ctx* ctx_;
-};
+keymaster_error_t OcbDecryptKey(const AuthorizationSet& hw_enforced,
+ const AuthorizationSet& sw_enforced, const AuthorizationSet& hidden,
+ const KeymasterKeyBlob& master_key,
+ const KeymasterKeyBlob& ciphertext, const Buffer& nonce,
+ const Buffer& tag, KeymasterKeyBlob* plaintext);
} // namespace keymaster