17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen struct dcrypt_private_key **priv_key_r ATTR_UNUSED,
8836c374dc344a48d4f6cefdf224089f3a0c40c6Stephan Bosch const char **digest_r = (const char**)context;
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainenstatic void dcrypt_istream_dump_metadata(const struct istream *stream)
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen enum io_stream_encrypt_flags flags = i_stream_encrypt_get_flags(stream);
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen if ((flags & IO_STREAM_ENC_INTEGRITY_HMAC) != 0)
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen printf("flags: IO_STREAM_ENC_INTEGRITY_HMAC\n");
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen if ((flags & IO_STREAM_ENC_INTEGRITY_AEAD) != 0)
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen printf("flags: IO_STREAM_ENC_INTEGRITY_AEAD\n");
d29c3ac4da9857ffcce57eec726d042c292e2becTimo Sirainen if ((flags & IO_STREAM_ENC_INTEGRITY_NONE) != 0)
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen printf("flags: IO_STREAM_ENC_INTEGRITY_NONE\n");
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen enum decrypt_istream_format format = i_stream_encrypt_get_format(stream);
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainenstatic bool dcrypt_file_dump_metadata(const char *filename, bool print)
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen struct istream *is = i_stream_create_file(filename, IO_BLOCK_SIZE);
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen struct istream *ds = i_stream_create_decrypt_callback(is,
7d102c66eb1755e1894cf56e3594cd744e855238Timo Sirainen printf("decrypt key digest: %s\n", key_digest);
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainenstatic bool test_dump_dcrypt_file(const char *path)
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen if (!dcrypt_initialize("openssl", NULL, NULL))
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen bool ret = dcrypt_file_dump_metadata(path, FALSE);
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainenstatic void cmd_dump_dcrypt_file(int argc ATTR_UNUSED, char *argv[])
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen if (!dcrypt_initialize("openssl", NULL, &error))
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen i_fatal("dcrypt_initialize failed: %s", error);