/*
SSSD - certificate handling utils - OpenSSL version
The calls defined here should be useable outside of SSSD as well, e.g. in
libsss_certmap.
Copyright (C) Sumit Bose <sbose@redhat.com> 2017
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 <talloc.h>
#include <openssl/safestack.h>
#include "util/crypto/sss_crypto.h"
#include "lib/certmap/sss_certmap.h"
#include "lib/certmap/sss_certmap_int.h"
/* backward compatible macros for OpenSSL < 1.1 */
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
typedef struct PrincipalName_st {
typedef struct KRB5PrincipalName_st {
{
switch (type) {
case GEN_OTHERNAME:
return SAN_OTHER_NAME;
case GEN_EMAIL:
return SAN_RFC822_NAME;
case GEN_DNS:
return SAN_DNS_NAME;
case GEN_X400:
return SAN_X400_ADDRESS;
case GEN_DIRNAME:
return SAN_DIRECTORY_NAME;
case GEN_EDIPARTY:
return SAN_EDIPART_NAME;
case GEN_URI:
return SAN_URI;
case GEN_IPADD:
return SAN_IP_ADDRESS;
case GEN_RID:
return SAN_REGISTERED_ID;
default:
return SAN_INVALID;
}
}
{
int ret;
int len;
unsigned char *p;
if (len <= 0) {
return EINVAL;
}
if (i == NULL) {
return ENOMEM;
}
if (i->other_name_oid == NULL) {
goto done;
}
if (len <= 0) {
goto done;
}
goto done;
}
/* i2d_TYPE increment the second argument so that it points to the end of
* the written data hence we cannot use i->bin_val directly. */
p = i->bin_val;
ret = 0;
done:
if (ret == 0) {
*item = i;
} else {
talloc_free(i);
}
return ret;
}
{
int ret;
return EINVAL;
}
if (i == NULL) {
return ENOMEM;
}
i->val = talloc_strndup(i,
(const char *) ASN1_STRING_get0_data(
goto done;
}
if (ret != 0) {
goto done;
}
ret = 0;
done:
if (ret == 0) {
*item = i;
} else {
talloc_free(i);
}
return ret;
}
{
return NULL;
}
{
int ret;
size_t c;
const unsigned char *p;
const ASN1_STRING *oct;
return EINVAL;
}
== 0) {
goto done;
}
if (i == NULL) {
goto done;
}
goto done;
}
for (c = 0;
c++) {
if (c > 0) {
goto done;
}
}
(const char *) ASN1_STRING_get0_data(name_comp),
goto done;
}
}
goto done;
}
if (ret != 0) {
goto done;
}
ret = 0;
done:
if (ret == 0) {
*item = i;
} else {
talloc_free(i);
}
return ret;
}
{
if (i == NULL) {
return ENOMEM;
}
talloc_free(i);
return ENOMEM;
}
*item = i;
return 0;
}
const char ***rdn_list)
{
int ret;
size_t c;
X509_NAME_ENTRY *e;
char *tmp_str;
long tmp_str_size;
int nid;
const char *sn;
goto done;
}
goto done;
}
for (c = 0; c < X509_NAME_entry_count(name); c++) {
e = X509_NAME_get_entry(name, c);
if (ret < 0) {
goto done;
}
if (tmp_str_size == 0) {
goto done;
}
(int) tmp_str_size, tmp_str);
if (ret != 1) {
/* BIO_reset() for BIO_s_mem returns 1 for sucess */
goto done;
}
goto done;
}
}
ret = 0;
done:
if (ret == 0) {
} else {
}
return ret;
}
{
int ret;
if (i == NULL) {
return ENOMEM;
}
if (ret != 0) {
talloc_free(i);
return ret;
}
*item = i;
return 0;
}
{
int len;
if (len <= 0) {
return EINVAL;
}
if (i == NULL) {
return ENOMEM;
}
talloc_free(i);
return ENOMEM;
}
*item = i;
return 0;
}
{
size_t c;
int ret;
int crit;
int len;
unsigned char *data;
unsigned char *p;
return EOK;
} else {
return EINVAL;
}
}
for (c = 0; c < sk_GENERAL_NAME_num(extsan); c++) {
case GEN_OTHERNAME:
&item_s);
if (ret != 0) {
goto done;
}
&item_p);
if (ret != 0) {
goto done;
}
if (ret != 0) {
goto done;
}
}
if (ret != 0) {
goto done;
}
}
break;
break;
case GEN_EMAIL:
&item);
if (ret != 0) {
goto done;
}
if (ret != 0) {
goto done;
}
break;
case GEN_DNS:
&item);
if (ret != 0) {
goto done;
}
if (ret != 0) {
goto done;
}
break;
case GEN_URI:
&item);
if (ret != 0) {
goto done;
}
break;
case GEN_IPADD:
&item);
if (ret != 0) {
goto done;
}
break;
case GEN_DIRNAME:
if (ret != 0) {
goto done;
}
break;
case GEN_RID:
if (ret != 0) {
goto done;
}
break;
case GEN_X400:
if (len <= 0) {
goto done;
}
goto done;
}
/* i2d_TYPE increment the second argument so that it points to the end of
* the written data hence we cannot use i->bin_val directly. */
p = data;
if (ret != 0) {
goto done;
}
break;
case GEN_EDIPARTY:
if (len <= 0) {
goto done;
}
goto done;
}
/* i2d_TYPE increment the second argument so that it points to the end of
* the written data hence we cannot use i->bin_val directly. */
p = data;
if (ret != 0) {
goto done;
}
break;
default:
goto done;
}
}
done:
}
return ret;
}
const char ***_oids)
{
size_t c;
int ret;
int len;
return EIO;
}
return ENOMEM;
}
for (c = 0; c < sk_ASN1_OBJECT_num(extusage); c++) {
if (len < 0) {
return EIO;
}
goto done;
}
}
ret = 0;
done:
if (ret == 0) {
} else {
}
return ret;
}
struct sss_cert_content **content)
{
int ret;
const unsigned char *der;
return EINVAL;
}
return ENOMEM;
}
goto done;
}
goto done;
}
if (ret != 0) {
goto done;
}
&cont->issuer_str);
if (ret != 0) {
goto done;
}
if (ret != 0) {
goto done;
}
&cont->subject_str);
if (ret != 0) {
goto done;
}
if (ret < 0) {
goto done;
}
goto done;
}
&(cont->extended_key_usage_oids));
if (ret != 0) {
goto done;
}
if (ret != 0) {
goto done;
}
goto done;
}
done:
} else {
}
return ret;
}