/*
SSSD - certificate handling utils - NSS version
Copyright (C) Sumit Bose <sbose@redhat.com> 2015
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 <nss.h>
#include <cert.h>
#include <base64.h>
#include <key.h>
#include <prerror.h>
#include <ocsp.h>
#include <talloc.h>
#include "util/crypto/sss_crypto.h"
#include "util/crypto/nss/nss_util.h"
#include "util/sss_endian.h"
{
int ret;
size_t c;
size_t d;
/* initialize NSS if needed */
ret = nspr_nss_init();
return ret;
}
return EINVAL;
}
if (ascii_crlf == NULL) {
goto done;
}
goto done;
}
d = 0;
for (c = 0; c < ascii_crlf_len; c++) {
if (ascii_crlf[c] != '\r') {
ascii_lf[d++] = ascii_crlf[c];
}
}
if (pem_cert_str == NULL) {
goto done;
}
}
*pem = pem_cert_str;
pem_cert_str = NULL;
}
done:
return ret;
}
{
const char *ps;
const char *pe;
ATOB_AsciiToData */
int ret;
/* initialize NSS if needed */
ret = nspr_nss_init();
return ret;
}
return EINVAL;
}
return EINVAL;
}
return EINVAL;
}
return EINVAL;
}
pe--;
}
return EINVAL;
}
goto done;
}
return EIO;
}
goto done;
}
goto done;
}
}
}
done:
return ret;
}
struct cert_verify_opts *cert_verify_opts,
{
int ret;
size_t c;
return EINVAL;
}
/* initialize NSS with context, we might have already called
* NSS_NoDB_Init() but for validation we need to have access to a DB with
* the trusted issuer cert. Only NSS_InitContext will really open the DB
* in this case. I'm not sure about how long validation might need e.g. if
* CRLs or OSCP is enabled, maybe it would be better to run validation in
* p11_child? */
PR_GetError());
return EIO;
}
if (cert_verify_opts->do_ocsp) {
if (rv != SECSuccess) {
PR_GetError());
return EIO;
}
if (rv != SECSuccess) {
"CERT_SetOCSPDefaultResponder failed: [%d].\n",
PR_GetError());
return EIO;
}
if (rv != SECSuccess) {
"CERT_EnableOCSPDefaultResponder failed: [%d].\n",
PR_GetError());
return EIO;
}
}
}
goto done;
}
if (cert_verify_opts->do_verification) {
/* Disable OCSP default responder so that NSS can shutdown properly */
if (cert_verify_opts->do_ocsp
!= NULL) {
if (rv != SECSuccess) {
"CERT_DisableOCSPDefaultResponder failed: [%d].\n",
PR_GetError());
}
}
if (rv_verify != SECSuccess) {
PR_GetError());
goto done;
}
}
if (cert_pub_key == NULL) {
goto done;
}
"Expected RSA public key, found unsupported [%d].\n",
goto done;
}
/* Looks like nss drops the leading 00 which AFAIK is added to make sure
* the bigint is handled as positive number if the leading bit is set. */
exponent_prefix_len = 0;
exponent_prefix_len = 1;
}
modulus_prefix_len = 0;
modulus_prefix_len = 1;
}
goto done;
}
c = 0;
SAFEALIGN_SET_UINT32(&buf[c],
+ exponent_prefix_len), &c);
if (exponent_prefix_len == 1) {
}
SAFEALIGN_SET_UINT32(&buf[c],
+ modulus_prefix_len ), &c);
if (modulus_prefix_len == 1) {
}
done:
}
if (rv != SECSuccess) {
PR_GetError());
}
return ret;
}