at the internal API-level, preserve the capability of setting IV
diff --git a/lib/fusion.c b/lib/fusion.c
index 43645c9..3af2bd1 100644
--- a/lib/fusion.c
+++ b/lib/fusion.c
@@ -929,6 +929,8 @@
 
     ctx->static_iv = loadn(iv, PTLS_AESGCM_IV_SIZE);
     ctx->static_iv = _mm_shuffle_epi8(ctx->static_iv, bswap8);
+    if (key == NULL)
+        return 0;
 
     ctx->super.dispose_crypto = aesgcm_dispose_crypto;
     ctx->super.do_encrypt_init = aead_do_encrypt_init;
diff --git a/lib/openssl.c b/lib/openssl.c
index 4bf92ae..d907346 100644
--- a/lib/openssl.c
+++ b/lib/openssl.c
@@ -859,6 +859,10 @@
     struct aead_crypto_context_t *ctx = (struct aead_crypto_context_t *)_ctx;
     int ret;
 
+    memcpy(ctx->static_iv, iv, ctx->super.algo->iv_size);
+    if (key == NULL)
+        return 0;
+
     ctx->super.dispose_crypto = aead_dispose_crypto;
     if (is_enc) {
         ctx->super.do_encrypt_init = aead_do_encrypt_init;
@@ -893,7 +897,6 @@
         ret = PTLS_ERROR_LIBRARY;
         goto Error;
     }
-    memcpy(ctx->static_iv, iv, ctx->super.algo->iv_size);
 
     return 0;