From: Kyungwook Tak Date: Thu, 20 Oct 2016 09:35:32 +0000 (+0900) Subject: Add comment for exception info X-Git-Tag: submit/trunk/20170823.075128~87^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=003da81ee93041f7f4ed52aa009bfd079af2da84;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Add comment for exception info Change-Id: Ic2017f3d80380700fd8359eacf4efddb455a35a7 Signed-off-by: Kyungwook Tak --- diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Certificate.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Certificate.cs index 5e006de..8e96852 100644 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Certificate.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Certificate.cs @@ -29,6 +29,8 @@ namespace Tizen.Security.SecureRepository /// Load Certificate from the given file path. /// /// The path of certificate file to be loaded. + /// Loaded certificate class instance. + /// Invalid certificate file format. Provided file path does not exist or cannot be accessed. static public Certificate Load(string filePath) { IntPtr ptr = new IntPtr(); @@ -93,7 +95,7 @@ namespace Tizen.Security.SecureRepository /// /// When overridden in a derived class, executes the code required to free the handle. /// - /// true if the handle is released successfully + /// true if the handle is released successfully. protected override bool ReleaseHandle() { if (IsInvalid) // do not release diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/CertificateManager.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/CertificateManager.cs index 1ab0a26..cf16dfc 100644 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/CertificateManager.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/CertificateManager.cs @@ -29,9 +29,13 @@ namespace Tizen.Security.SecureRepository /// /// The name of a certificate to retrieve. /// The password used in decrypting a certificate value. - /// If password of policy is provided in SaveCertificate(), the same password should be provided + /// If password of policy is provided in SaveCertificate(), the same password should be provided. /// /// A certificate specified by alias. + /// Alias argument is null or invalid format. + /// + /// Certificate does not exist with the alias or certificate-protecting password isn't matched. + /// static public Certificate Get(string alias, string password) { IntPtr ptr = new IntPtr(); @@ -45,7 +49,8 @@ namespace Tizen.Security.SecureRepository /// /// Gets all alias of certificates which the client can access. /// - /// all alias of certificates which the client can access. + /// All alias of certificates which the client can access. + /// No alias to get. static public IEnumerable GetAliases() { IntPtr ptr = new IntPtr(); @@ -61,6 +66,8 @@ namespace Tizen.Security.SecureRepository /// The name of a certificate to be stored. /// The certificate's binary value to be stored. /// The policy about how to store a certificate securely. + /// Alias argument is null or invalid format. cert argument is invalid format. + /// Certificate with alias does already exist. static public void Save(string alias, Certificate cert, Policy policy) { int ret = Interop.CkmcManager.SaveCert(alias, cert.ToCkmcCert(), policy.ToCkmcPolicy()); @@ -73,7 +80,14 @@ namespace Tizen.Security.SecureRepository /// The certificate to be verified. /// The untrusted CA certificates to be used in verifying a certificate chain. /// A newly created certificate chain. + /// Some of certificate in arguments is invalid. + /// + /// Some of certificate in arguments is expired or not valid yet. + /// Certificate cannot build chain. + /// Root certificate is not in trusted system certificate store. + /// /// The trusted root certificate of the chain should exist in the system's certificate storage. + /// The trusted root certificate of the chain in system's certificate storage is added to the certificate chain. static public IEnumerable GetCertificateChain(Certificate certificate, IEnumerable untrustedCertificates) { @@ -97,6 +111,13 @@ namespace Tizen.Security.SecureRepository /// The trusted CA certificates to be used in verifying a certificate chain. /// The flag indicating the use of the trusted root certificates in the system's certificate storage. /// A newly created certificate chain. + /// Some of certificate in arguments is invalid. + /// + /// Some of certificate in arguments is expired or not valid yet. + /// Certificate cannot build chain. + /// Root certificate is not in trusted system certificate store. + /// + /// The trusted root certificate of the chain in system's certificate storage is added to the certificate chain. static public IEnumerable GetCertificateChain(Certificate certificate, IEnumerable untrustedCertificates, IEnumerable trustedCertificates, @@ -121,6 +142,8 @@ namespace Tizen.Security.SecureRepository /// /// Valid certificate chain to perform OCSP check. /// A status result of OCSP check. + /// certificateChain is not valid chain or certificate. + /// some of certificate in chain is expired or not valid yet. static public OcspStatus CheckOcsp(IEnumerable certificateChain) { int ocspStatus = (int)OcspStatus.Good; diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/Cipher.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/Cipher.cs index 0fd3014..f051e6c 100644 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/Cipher.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/Cipher.cs @@ -51,6 +51,14 @@ namespace Tizen.Security.SecureRepository.Crypto /// Data to be decrypted (some algorithms may require additional /// information embedded in encrypted data.AES GCM is an example). /// Decrypted data. + /// + /// Mandatory algorithm parameter is missing or invalid. + /// Optional algorithm parameter is invalid. + /// + /// + /// Key-protecting password isn't matched. + /// Key does not exist with keyAlias. + /// /// The key type specified by keyAlias should be compatible with the algorithm specified in Parameters. public byte[] Decrypt(string keyAlias, string password, byte[] cipherText) { @@ -73,6 +81,14 @@ namespace Tizen.Security.SecureRepository.Crypto /// For RSA the size must be smaller or equal to (key_size_in bytes - 42). /// Example: for 1024 RSA key the maximum data size is 1024/8 - 42 = 86. /// Encrypted data. + /// + /// Mandatory algorithm parameter is missing or invalid. + /// Optional algorithm parameter is invalid. + /// + /// + /// Key-protecting password isn't matched. + /// Key does not exist with keyAlias. + /// /// The key type specified by keyAlias should be compatible with the algorithm specified in Parameters. public byte[] Encrypt(string keyAlias, string password, byte[] plainText) { diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/CipherParameters.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/CipherParameters.cs index 795dd96..e52d426 100644 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/CipherParameters.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/CipherParameters.cs @@ -40,6 +40,7 @@ namespace Tizen.Security.SecureRepository.Crypto /// /// Parameter name. /// Parameter value. + /// CipherParameterName is invalid. protected void Add(CipherParameterName name, long value) { int ret = Interop.CkmcTypes.ParamListSetInteger(PtrCkmcParamList, (int)name, value); @@ -51,6 +52,7 @@ namespace Tizen.Security.SecureRepository.Crypto /// /// Parameter name. /// Parameter value. + /// CipherParameterName is invalid. protected void Add(CipherParameterName name, byte[] value) { Interop.CkmcRawBuffer rawBuff = new Interop.CkmcRawBuffer(new PinnedObject(value), value.Length); @@ -62,6 +64,10 @@ namespace Tizen.Security.SecureRepository.Crypto /// Gets integer parameter. /// /// Parameter name. + /// + /// CipherParameterName is invalid. + /// No parameter set with the name. + /// public long GetInteger(CipherParameterName name) { long value = 0; @@ -74,6 +80,10 @@ namespace Tizen.Security.SecureRepository.Crypto /// Gets byte array parameter. /// /// Parameter name. + /// + /// CipherParameterName is invalid. + /// No parameter set with the name. + /// public byte[] GetBuffer(CipherParameterName name) { IntPtr ptr = new IntPtr(); diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/Signature.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/Signature.cs index 5a64256..b2b1108 100644 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/Signature.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Crypto/Signature.cs @@ -49,6 +49,11 @@ namespace Tizen.Security.SecureRepository.Crypto /// The password used in decrypting a private key value. /// The message that is signed with a private key. /// A newly created signature. + /// privateKeyAlias is null or invalid format. + /// + /// Key-protecting password isn't matched. + /// Key does not exist with privateKeyAlias. + /// /// The key type specified by privateKeyAlias should be compatible with the algorithm specified in Parameters. /// If password of policy is provided during storing a key, the same password should be provided. public byte[] Sign(string privateKeyAlias, string password, byte[] message) @@ -84,7 +89,12 @@ namespace Tizen.Security.SecureRepository.Crypto /// The password used in decrypting a public key value. /// The input on which the signature is created. /// The signature that is verified with public key. - /// The signature statue. True is returned when the signature is valid + /// The signature status. True is returned when the signature is valid. + /// publicKeyAlias is null or invalid format. + /// + /// Key-protecting password isn't matched. + /// Key does not exist with publicKeyAlias. + /// /// The key type specified by publicKeyAlias should be compatible with the algorithm specified in Parameters. /// If password of policy is provided during storing a key, the same password should be provided. public bool Verify(string publicKeyAlias, string password, byte[] message, byte[] signature) diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/DataManager.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/DataManager.cs index 5a09bb5..8b112c3 100644 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/DataManager.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/DataManager.cs @@ -29,9 +29,13 @@ namespace Tizen.Security.SecureRepository /// /// The name of a certificate to retrieve. /// The password used in decrypting a data value. - /// If password of policy is provided in SaveData(), the same password should be provided + /// If password of policy is provided in SaveData(), the same password should be provided. /// - /// data specified by alias. + /// Data specified by alias. + /// Alias argument is null or invalid format. + /// + /// Data does not exist with the alias or data-protecting password isn't matched. + /// static public byte[] Get(string alias, string password) { IntPtr ptr = new IntPtr(); @@ -45,7 +49,8 @@ namespace Tizen.Security.SecureRepository /// /// Gets all alias of data which the client can access. /// - /// all alias of data which the client can access. + /// All alias of data which the client can access. + /// No alias to get. static public IEnumerable GetAliases() { IntPtr ptr = new IntPtr(); @@ -61,6 +66,8 @@ namespace Tizen.Security.SecureRepository /// The name of data to be stored. /// The binary value to be stored. /// The policy about how to store data securely. + /// Alias argument is null or invalid format. Data policy cannot be unextractable. + /// Data with alias does already exist. static public void Save(string alias, byte[] data, Policy policy) { Interop.CkmcRawBuffer rawBuff = new Interop.CkmcRawBuffer(new PinnedObject(data), data.Length); diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/KeyManager.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/KeyManager.cs index 5077fcc..69d206a 100644 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/KeyManager.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/KeyManager.cs @@ -28,10 +28,15 @@ namespace Tizen.Security.SecureRepository /// Gets a key from secure repository. /// /// The name of a key to retrieve. - /// The password used in decrypting a key value. - /// If password of policy is provided in SaveKey(), the same password should be provided + /// + /// The password used in decrypting a key value. + /// If password of policy is provided in SaveKey(), the same password should be provided. /// /// A key specified by alias. + /// Alias argument is null or invalid format. + /// + /// Key does not exist with the alias or key-protecting password isn't matched. + /// static public Key Get(string alias, string password) { IntPtr ptr = new IntPtr(); @@ -45,7 +50,8 @@ namespace Tizen.Security.SecureRepository /// /// Gets all alias of keys which the client can access. /// - /// all alias of keys which the client can access. + /// All alias of keys which the client can access. + /// No alias to get. static public IEnumerable GetAliases() { IntPtr ptr = new IntPtr(); @@ -61,6 +67,8 @@ namespace Tizen.Security.SecureRepository /// The name of a key to be stored. /// The key's binary value to be stored. /// The policy about how to store a key securely. + /// Alias argument is null or invalid format. key argument is invalid format. + /// Key with alias does already exist. /// Type in key may be set to KeyType.None as an input. Type is determined inside secure reposioty during storing keys. /// If password in policy is provided, the key is additionally encrypted with the password in policy. static public void Save(string alias, Key key, Policy policy) @@ -77,6 +85,8 @@ namespace Tizen.Security.SecureRepository /// The name of public key to be stored. /// The policy about how to store a private key securely. /// The policy about how to store a public key securely. + /// size is invalid. privateKeyAlias or publicKeyAlias is null or invalid format. + /// Key with privateKeyAlias or publicKeyAlias does already exist. /// If password in policy is provided, the key is additionally encrypted with the password in policy. static public void CreateRsaKeyPair(int size, string privateKeyAlias, string publicKeyAlias, Policy privateKeyPolicy, Policy publicKeyPolicy) @@ -94,6 +104,8 @@ namespace Tizen.Security.SecureRepository /// The name of public key to be stored. /// The policy about how to store a private key securely. /// The policy about how to store a public key securely. + /// size is invalid. privateKeyAlias or publicKeyAlias is null or invalid format. + /// Key with privateKeyAlias or publicKeyAlias does already exist. /// If password in policy is provided, the key is additionally encrypted with the password in policy. static public void CreateDsaKeyPair(int size, string privateKeyAlias, string publicKeyAlias, Policy privateKeyPolicy, Policy publicKeyPolicy) @@ -111,6 +123,8 @@ namespace Tizen.Security.SecureRepository /// The name of public key to be stored. /// The policy about how to store a private key securely. /// The policy about how to store a public key securely. + /// Elliptic curve type is invalid. privateKeyAlias or publicKeyAlias is null or invalid format. + /// Key with privateKeyAlias or publicKeyAlias does already exist. /// If password in policy is provided, the key is additionally encrypted with the password in policy. static public void CreateEcdsaKeyPair(EllipticCurveType type, string privateKeyAlias, string publicKeyAlias, Policy privateKeyPolicy, Policy publicKeyPolicy) @@ -126,6 +140,8 @@ namespace Tizen.Security.SecureRepository /// The size of key strength to be created. 128, 192 and256 are supported. /// The name of key to be stored. /// The policy about how to store the key securely. + /// Key size is invalid. keyAlias is null or invalid format. + /// Key with privateKeyAlias or publicKeyAlias does already exist. /// If password in policy is provided, the key is additionally encrypted with the password in policy. static public void CreateAesKey(int size, string keyAlias, Policy policy) { diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Manager.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Manager.cs old mode 100644 new mode 100755 index 2e7a01a..0220274 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Manager.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Manager.cs @@ -14,6 +14,8 @@ * limitations under the License */ +using System; + namespace Tizen.Security.SecureRepository { /// @@ -46,6 +48,8 @@ namespace Tizen.Security.SecureRepository /// Removes a an entry (no matter of type) from the key manager. /// /// Item alias to be removed. + /// alias is null or invalid format. + /// alias does not exist. /// To remove item, client must have remove permission to the specified item. /// The item owner can remove by default. static public void RemoveAlias(string alias) @@ -60,6 +64,8 @@ namespace Tizen.Security.SecureRepository /// Item alias for which access will be granted. /// Package id of the application that will gain access rights. /// Mask of permissions(Permission enum) granted for an application with otherPackageId. + /// alias or otherPackageId is null or invalid format. + /// alias does not exist. /// Data identified by alias should exist. /// The item owner can set permissions. static public void SetPermission(string alias, string otherPackageId, int permissions) diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Pkcs12.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Pkcs12.cs index c6b7ce2..7fc49ee 100644 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Pkcs12.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Pkcs12.cs @@ -33,6 +33,13 @@ namespace Tizen.Security.SecureRepository /// The path of PKCS12 file to be loaded. /// The passphrase used to decrypt the PCKS12 file. /// If PKCS12 file is not encrypted, passphrase can be null. + /// filePath is null. + /// + /// No file on filePath. + /// No permission to access file. + /// File is invalid PKCS12 format. + /// File cannot be extracted with provided filePassword. + /// static public Pkcs12 Load(string filePath, string filePassword) { IntPtr ptr = new IntPtr(); diff --git a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Pkcs12Manager.cs b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Pkcs12Manager.cs index e4ec008..e1c66df 100644 --- a/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Pkcs12Manager.cs +++ b/src/Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Pkcs12Manager.cs @@ -34,6 +34,12 @@ namespace Tizen.Security.SecureRepository /// If password of certificatePolicy is provided in SavePkcs12(), the same password should be provided /// /// A Pkcs12 data specified by alias. + /// Alias argument is null or invalid format. + /// + /// Pkcs12 does not exist with the alias. + /// Optional password of key in Pkcs12 isn't matched. + /// Optional password of certificate in Pkcs12 isn't matched. + /// static public Pkcs12 Get(string alias, string keyPassword, string cerificatePassword) { IntPtr ptr = new IntPtr(); @@ -52,6 +58,8 @@ namespace Tizen.Security.SecureRepository /// The pkcs12 data to be stored. /// The policy about how to store pkcs's private key. /// The policy about how to store pkcs's certificate. + /// Alias argument is null or invalid format. Pkcs12 argument is invalid format. + /// Pkcs12 with alias does already exist. static public void Save(string alias, Pkcs12 pkcs12, Policy keyPolicy, Policy certificatePolicy) { int ret = Interop.CkmcManager.SavePkcs12(alias,