1 // Copyright 2021 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 /////////////////////////////////////////////////////////////////////////////// 16 17 #include "tink/jwt/internal/jwt_hmac_key_manager.h" 18 19 #include <map> 20 #include <string> 21 22 #include "absl/strings/string_view.h" 23 #include "tink/jwt/internal/raw_jwt_hmac_key_manager.h" 24 #include "tink/mac.h" 25 #include "tink/subtle/hmac_boringssl.h" 26 #include "tink/subtle/random.h" 27 #include "tink/util/enums.h" 28 #include "tink/util/errors.h" 29 #include "tink/util/input_stream_util.h" 30 #include "tink/util/protobuf_helper.h" 31 #include "tink/util/status.h" 32 #include "tink/util/statusor.h" 33 #include "tink/util/validation.h" 34 #include "proto/common.pb.h" 35 #include "proto/jwt_hmac.pb.h" 36 #include "proto/tink.pb.h" 37 38 namespace crypto { 39 namespace tink { 40 namespace jwt_internal { 41 42 using crypto::tink::util::Status; 43 using crypto::tink::util::StatusOr; 44 using google::crypto::tink::JwtHmacKey; 45 using google::crypto::tink::JwtHmacKeyFormat; 46 get_version() const47uint32_t JwtHmacKeyManager::get_version() const { 48 return raw_key_manager_.get_version(); 49 } 50 51 google::crypto::tink::KeyData::KeyMaterialType key_material_type() const52JwtHmacKeyManager::key_material_type() const { 53 return raw_key_manager_.key_material_type(); 54 } 55 get_key_type() const56const std::string& JwtHmacKeyManager::get_key_type() const { 57 return raw_key_manager_.get_key_type(); 58 } 59 CreateKey(const JwtHmacKeyFormat & jwt_hmac_key_format) const60StatusOr<JwtHmacKey> JwtHmacKeyManager::CreateKey( 61 const JwtHmacKeyFormat& jwt_hmac_key_format) const { 62 return raw_key_manager_.CreateKey(jwt_hmac_key_format); 63 } 64 DeriveKey(const JwtHmacKeyFormat & jwt_hmac_key_format,InputStream * input_stream) const65StatusOr<JwtHmacKey> JwtHmacKeyManager::DeriveKey( 66 const JwtHmacKeyFormat& jwt_hmac_key_format, 67 InputStream* input_stream) const { 68 return raw_key_manager_.DeriveKey(jwt_hmac_key_format, input_stream); 69 } 70 ValidateKey(const JwtHmacKey & key) const71Status JwtHmacKeyManager::ValidateKey(const JwtHmacKey& key) const { 72 return raw_key_manager_.ValidateKey(key); 73 } 74 ValidateKeyFormat(const JwtHmacKeyFormat & key_format) const75Status JwtHmacKeyManager::ValidateKeyFormat( 76 const JwtHmacKeyFormat& key_format) const { 77 return raw_key_manager_.ValidateKeyFormat(key_format); 78 } 79 80 } // namespace jwt_internal 81 } // namespace tink 82 } // namespace crypto 83