diff options
author | Shreyas Kalyan <shreyas.kalyan@10gen.com> | 2019-03-05 13:02:35 -0500 |
---|---|---|
committer | Shreyas Kalyan <shreyas.kalyan@10gen.com> | 2019-03-21 12:02:43 -0400 |
commit | 0adb2f088e4326c35d82afa42e9e5d5969530c5a (patch) | |
tree | 8ea58ec95409ae9206a1975f56acf25ba0f8dcfa /src/mongo/crypto/sha512_block.h | |
parent | 9dc7556e1f02e09956ec60118fa7a1bfa3edad98 (diff) | |
download | mongo-0adb2f088e4326c35d82afa42e9e5d5969530c5a.tar.gz |
SERVER-39893 Implement AEAD_AES_256_CBC_HMAC_SHA_512
Diffstat (limited to 'src/mongo/crypto/sha512_block.h')
-rw-r--r-- | src/mongo/crypto/sha512_block.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/mongo/crypto/sha512_block.h b/src/mongo/crypto/sha512_block.h new file mode 100644 index 00000000000..af8350d19e3 --- /dev/null +++ b/src/mongo/crypto/sha512_block.h @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2019-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/crypto/sha_block.h" + +#include "mongo/util/make_array_type.h" + +namespace mongo { + +/** + * A Traits type for adapting SHABlock to sha512 hashes. + */ +struct SHA512BlockTraits { + using HashType = MakeArrayType<std::uint8_t, 64, SHA512BlockTraits>; + + static constexpr StringData name = "SHA512Block"_sd; + + static HashType computeHash(std::initializer_list<ConstDataRange> input); + + static void computeHmac(const uint8_t* key, + size_t keyLen, + std::initializer_list<ConstDataRange> input, + HashType* const output); + + static HashType computeHmac(const uint8_t* key, + size_t keyLen, + std::initializer_list<ConstDataRange> input); +}; + +using SHA512Block = SHABlock<SHA512BlockTraits>; + +} // namespace mongo |