4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync PEM (Privacy Enhanced Mail) Format Handler Wrapper Implementation over OpenSSL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncCopyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncThis program and the accompanying materials
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncare licensed and made available under the terms and conditions of the BSD License
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncwhich accompanies this distribution. The full text of the license may be found at
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Callback function for password phrase conversion used for retrieving the encrypted PEM.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] Buf Pointer to the buffer to write the passphrase to.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Size Maximum length of the passphrase (i.e. the size of Buf).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Flag A flag which is set to 0 when reading and 1 when writing.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Key Key data to be passed to the callback routine.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval The number of characters in the passphrase or 0 if an error occurred.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Duplicate key phrase directly.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync KeyLength = (KeyLength > Size ) ? Size : KeyLength;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Retrieve the RSA Private Key from the password-protected PEM key data.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] PemSize Size of the PEM key data in bytes.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RSA private key component. Use RsaFree() function to free the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If PemData is NULL, then return FALSE.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If RsaContext is NULL, then return FALSE.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval TRUE RSA Private Key was retrieved successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval FALSE Invalid PEM key data or incorrect password.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check input parameters.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (PemData == NULL || RsaContext == NULL || PemSize > INT_MAX) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Add possible block-cipher descriptor for PEM data decryption.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // NOTE: Only support most popular ciphers (3DES, AES) for the encrypted PEM.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Read encrypted PEM Data.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Retrieve RSA Private Key from encrypted PEM data.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync *RsaContext = PEM_read_bio_RSAPrivateKey (PemBio, NULL, (pem_password_cb *)&PasswordCallback, (void *)Password);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Release Resources.