/*
SSSD
NSS crypto wrappers
Authors:
Sumit Bose <sbose@redhat.com>
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) Red Hat, Inc 2010
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <prinit.h>
#include <nss.h>
#include "util/crypto/nss/nss_util.h"
#include "util/crypto/nss/nss_crypto.h"
static int nspr_nss_init_done = 0;
int nspr_nss_init(void)
{
/* nothing to do */
if (sret != SECSuccess) {
"Error initializing connection to NSS [%d]\n",
PR_GetError());
return EIO;
}
nspr_nss_init_done = 1;
return EOK;
}
int nspr_nss_cleanup(void)
{
/* nothing to do */
if (nspr_nss_init_done == 0) return SECSuccess;
sret = NSS_Shutdown();
if (sret != SECSuccess) {
"Error shutting down connection to NSS [%d]\n",
PR_GetError());
return EIO;
}
PR_Cleanup();
nspr_nss_init_done = 0;
return EOK;
}
{
return EOK;
}
struct crypto_mech_data *mech_props,
{
int ret;
PR_GetError());
goto done;
}
if (sret != SECSuccess) {
PR_GetError());
goto done;
}
if (randkeydata == NULL) {
PR_GetError());
goto done;
}
/* randkeydata is valid until randkey is. Copy with talloc to
* get a nice memory hierarchy symmetrical in encrypt
* and decrypt case */
if (!key) {
goto done;
}
goto done;
}
done:
return ret;
}
struct crypto_mech_data *mech_props,
struct sss_nss_crypto_ctx **_cctx)
{
int ret;
if (!cctx) {
return ENOMEM;
}
PR_GetError());
goto done;
}
if (keylen > 0) {
"Failed to allocate Key buffer\n");
goto done;
}
if (key) {
} else {
"Could not generate encryption key\n");
goto done;
}
}
}
if (ivlen > 0) {
goto done;
}
if (iv) {
} else {
"Could not generate initialization vector\n");
goto done;
}
}
}
done:
return ret;
}
enum crypto_mech_op crypto_op,
struct sss_nss_crypto_ctx *cctx)
{
int ret;
switch (crypto_op) {
case op_encrypt:
op = CKA_ENCRYPT;
break;
case op_decrypt:
op = CKA_DECRYPT;
break;
case op_sign:
break;
default:
return EFAULT;
}
/* turn the raw key into a key object */
PR_GetError());
goto done;
}
/* turn the raw IV into a initialization vector object */
"Failure to set up PKCS11 param (err %d)\n",
PR_GetError());
goto done;
}
} else {
goto done;
}
}
/* Create cipher context */
PORT_GetError());
goto done;
}
done:
return ret;
}