]> git.saurik.com Git - apple/xnu.git/blobdiff - EXTERNAL_HEADERS/corecrypto/ccmode_siv.h
xnu-6153.11.26.tar.gz
[apple/xnu.git] / EXTERNAL_HEADERS / corecrypto / ccmode_siv.h
index 69069bb3a571c998734bb55f25f3b2a399db3b9a..1b05c638ea2eb2a6b67c5740d8c34051700bf0c5 100644 (file)
@@ -56,7 +56,7 @@ CC_INLINE size_t ccsiv_block_size(const struct ccmode_siv *mode)
 CC_INLINE size_t ccsiv_ciphertext_size(const struct ccmode_siv *mode,
                                        size_t plaintext_size)
 {
-    return plaintext_size+mode->cbc->block_size;
+    return plaintext_size + mode->cbc->block_size;
 }
 
 CC_INLINE size_t ccsiv_plaintext_size(const struct ccmode_siv *mode,
@@ -65,11 +65,10 @@ CC_INLINE size_t ccsiv_plaintext_size(const struct ccmode_siv *mode,
     if (ciphertext_size<mode->cbc->block_size) {
         return 0; // error
     }
-    return ciphertext_size-mode->cbc->block_size;
+    return ciphertext_size - mode->cbc->block_size;
 }
 
-// In theory, supported key sizes are 32, 48, 64 bytes
-// In practice, we only support key size 32 bytes due to cmac limitation
+// Supported key sizes are 32, 48, 64 bytes
 CC_INLINE int ccsiv_init(const struct ccmode_siv *mode, ccsiv_ctx *ctx,
                           size_t key_byte_len, const uint8_t *key)
 {
@@ -100,7 +99,6 @@ CC_INLINE int ccsiv_crypt(const struct ccmode_siv *mode, ccsiv_ctx *ctx,
 }
 
 // Clear all context for reuse.
-// Key is clear to avoid leaking it
 CC_INLINE int ccsiv_reset(const struct ccmode_siv *mode, ccsiv_ctx *ctx)
 {
     return mode->reset(ctx);
@@ -115,7 +113,8 @@ CC_INLINE int ccsiv_one_shot(const struct ccmode_siv *mode,
 {
     int rc;
     ccsiv_ctx_decl(mode->size, ctx);
-    ccsiv_init(mode, ctx, key_len, key);
+    rc=mode->init(mode, ctx, key_len, key);
+    if (rc) {return rc;}
     rc=mode->set_nonce(ctx, nonce_nbytes, nonce);
     if (rc) {return rc;}
     rc=mode->auth(ctx, adata_nbytes, adata);
@@ -126,13 +125,4 @@ CC_INLINE int ccsiv_one_shot(const struct ccmode_siv *mode,
     return rc;
 }
 
-void ccmode_factory_siv_encrypt(struct ccmode_siv *siv,
-                                const struct ccmode_cbc *cbc,
-                                const struct ccmode_ctr *ctr);
-
-void ccmode_factory_siv_decrypt(struct ccmode_siv *siv,
-                                const struct ccmode_cbc *cbc,
-                                const struct ccmode_ctr *ctr);
-
-
 #endif /* _CORECRYPTO_CCMODE_H_ */