Merge "[ACR][01/10/2013][Add|Deprecate]Adding ToInt8() method in Number, Int8, Intege...
[platform/framework/native/appfw.git] / src / security / FSecRsaKeyConverter.cpp
index 91c962d..b8f9bff 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -141,10 +140,10 @@ RsaKeyConverter::ConvertPrivateKeyFormatN(RsaKeyFormat format, const IPrivateKey
 
        if (isPemFormat == true)
        {
-               PrivateKey key;
-               r = key.SetKey(*pOutBuffer.get());
+               PrivateKey nKey;
+               r = nKey.SetKey(*pOutBuffer.get());
                SysTryCatch(NID_SEC, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
-               pOutBuffer = std::unique_ptr< ByteBuffer >(ConvertDerToPemN(format, key));
+               pOutBuffer = std::unique_ptr< ByteBuffer >(ConvertDerToPemN(format, nKey));
                SysTryCatch(NID_SEC, pOutBuffer != null, r = GetLastResult(), GetLastResult(), "[%s] Failed to convert der to pem encoded byte buffer");
        }
 
@@ -248,11 +247,11 @@ RsaKeyConverter::ConvertPublicKeyFormatN(RsaKeyFormat format, const IPublicKey&
 
        if (isPemFormat == true)
        {
-               PublicKey key;
-               r = key.SetKey(*pOutBuffer);
+               PublicKey nKey;
+               r = nKey.SetKey(*pOutBuffer);
                SysTryCatch(NID_SEC, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
-               pOutBuffer.reset(ConvertDerToPemN(format, key));
-               //pOutBuffer = std::unique_ptr< ByteBuffer >(ConvertDerToPemN(format, key));
+               pOutBuffer.reset(ConvertDerToPemN(format, nKey));
+               //pOutBuffer = std::unique_ptr< ByteBuffer >(ConvertDerToPemN(format, nKey));
                SysTryCatch(NID_SEC, pOutBuffer != null, r = GetLastResult(), GetLastResult(), "[%s] Failed to convert der to pem encoded byte buffer");
        }
 
@@ -352,6 +351,7 @@ RsaKeyConverter::ConvertDerToPemN(RsaKeyFormat format, const IKey& key)
                if (pPrivKeyInfo != null)
                {
                        pEvpKey = EVP_PKCS82PKEY(pPrivKeyInfo);
+                       SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid");
                        PKCS8_PRIV_KEY_INFO_free(pPrivKeyInfo);
                }
                pBio = BIO_new(BIO_s_mem());