void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len)
{
    CRYPTO_gcm128_finish(ctx, NULL, 0);
    memcpy(tag, ctx->Xi.c,
           len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));
}
['static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                          const unsigned char *in, size_t len)\n{\n    EVP_AES_GCM_CTX *gctx = ctx->cipher_data;\n    if (!gctx->key_set)\n        return -1;\n    if (gctx->tls_aad_len >= 0)\n        return aes_gcm_tls_cipher(ctx, out, in, len);\n    if (!gctx->iv_set)\n        return -1;\n    if (in) {\n        if (out == NULL) {\n            if (CRYPTO_gcm128_aad(&gctx->gcm, in, len))\n                return -1;\n        } else if (ctx->encrypt) {\n            if (gctx->ctr) {\n                size_t bulk = 0;\n# if defined(AES_GCM_ASM)\n                if (len >= 32 && AES_GCM_ASM(gctx)) {\n                    size_t res = (16 - gctx->gcm.mres) % 16;\n                    if (CRYPTO_gcm128_encrypt(&gctx->gcm, in, out, res))\n                        return -1;\n                    bulk = AES_gcm_encrypt(in + res,\n                                           out + res, len - res,\n                                           gctx->gcm.key, gctx->gcm.Yi.c,\n                                           gctx->gcm.Xi.u);\n                    gctx->gcm.len.u[1] += bulk;\n                    bulk += res;\n                }\n# endif\n                if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm,\n                                                in + bulk,\n                                                out + bulk,\n                                                len - bulk, gctx->ctr))\n                    return -1;\n            } else {\n                size_t bulk = 0;\n# if defined(AES_GCM_ASM2)\n                if (len >= 32 && AES_GCM_ASM2(gctx)) {\n                    size_t res = (16 - gctx->gcm.mres) % 16;\n                    if (CRYPTO_gcm128_encrypt(&gctx->gcm, in, out, res))\n                        return -1;\n                    bulk = AES_gcm_encrypt(in + res,\n                                           out + res, len - res,\n                                           gctx->gcm.key, gctx->gcm.Yi.c,\n                                           gctx->gcm.Xi.u);\n                    gctx->gcm.len.u[1] += bulk;\n                    bulk += res;\n                }\n# endif\n                if (CRYPTO_gcm128_encrypt(&gctx->gcm,\n                                          in + bulk, out + bulk, len - bulk))\n                    return -1;\n            }\n        } else {\n            if (gctx->ctr) {\n                size_t bulk = 0;\n# if defined(AES_GCM_ASM)\n                if (len >= 16 && AES_GCM_ASM(gctx)) {\n                    size_t res = (16 - gctx->gcm.mres) % 16;\n                    if (CRYPTO_gcm128_decrypt(&gctx->gcm, in, out, res))\n                        return -1;\n                    bulk = AES_gcm_decrypt(in + res,\n                                           out + res, len - res,\n                                           gctx->gcm.key,\n                                           gctx->gcm.Yi.c, gctx->gcm.Xi.u);\n                    gctx->gcm.len.u[1] += bulk;\n                    bulk += res;\n                }\n# endif\n                if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm,\n                                                in + bulk,\n                                                out + bulk,\n                                                len - bulk, gctx->ctr))\n                    return -1;\n            } else {\n                size_t bulk = 0;\n# if defined(AES_GCM_ASM2)\n                if (len >= 16 && AES_GCM_ASM2(gctx)) {\n                    size_t res = (16 - gctx->gcm.mres) % 16;\n                    if (CRYPTO_gcm128_decrypt(&gctx->gcm, in, out, res))\n                        return -1;\n                    bulk = AES_gcm_decrypt(in + res,\n                                           out + res, len - res,\n                                           gctx->gcm.key,\n                                           gctx->gcm.Yi.c, gctx->gcm.Xi.u);\n                    gctx->gcm.len.u[1] += bulk;\n                    bulk += res;\n                }\n# endif\n                if (CRYPTO_gcm128_decrypt(&gctx->gcm,\n                                          in + bulk, out + bulk, len - bulk))\n                    return -1;\n            }\n        }\n        return len;\n    } else {\n        if (!ctx->encrypt) {\n            if (gctx->taglen < 0)\n                return -1;\n            if (CRYPTO_gcm128_finish(&gctx->gcm, ctx->buf, gctx->taglen) != 0)\n                return -1;\n            gctx->iv_set = 0;\n            return 0;\n        }\n        CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf, 16);\n        gctx->taglen = 16;\n        gctx->iv_set = 0;\n        return 0;\n    }\n}', 'void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len)\n{\n    CRYPTO_gcm128_finish(ctx, NULL, 0);\n    memcpy(tag, ctx->Xi.c,\n           len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));\n}']