2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
18 using System.Collections.Generic;
20 namespace Tizen.Security.SecureRepository.Crypto
23 /// A abstract class holding parameters for signing and verification.
25 /// <since_tizen> 3 </since_tizen>
26 abstract public class SignatureParameters
28 private Dictionary<SignatureParameterName, int> _parameters;
31 /// Signature algorithm type.
33 /// <since_tizen> 3 </since_tizen>
34 public SignatureAlgorithmType SignatureAlgorithm
36 get { return (SignatureAlgorithmType)Get(SignatureParameterName.AlgorithmType); }
40 /// Hash algorithm used in signing anve verification.
42 /// <since_tizen> 3 </since_tizen>
43 public HashAlgorithm HashAlgorithm
45 get { return (HashAlgorithm)Get(SignatureParameterName.HashAlgorithm); }
46 set { Add(SignatureParameterName.HashAlgorithm, (int)value); }
49 // for inherited in internal only
50 internal SignatureParameters()
54 internal SignatureParameters(SignatureAlgorithmType algorithm)
56 _parameters = new Dictionary<SignatureParameterName, int>();
57 Add(SignatureParameterName.AlgorithmType, (int)algorithm);
60 internal void Add(SignatureParameterName name, int value)
62 _parameters.Add(name, value);
65 internal int Get(SignatureParameterName name)
67 if (_parameters.ContainsKey(name))
68 return _parameters[name];
70 throw new ArgumentException("No parameter for a given SignatureParameterName ");