summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/lib/hdb
diff options
context:
space:
mode:
authornectar <nectar@FreeBSD.org>2002-09-16 21:04:40 +0000
committernectar <nectar@FreeBSD.org>2002-09-16 21:04:40 +0000
commit8707f886593c300d83c76654e92ec76bcea9b858 (patch)
tree291ed09be4bd7c999ad1617a832aa3caae1cb274 /crypto/heimdal/lib/hdb
parenta77dba08ca7d8ad2f2dcd653974ac66df78cfa49 (diff)
downloadFreeBSD-src-8707f886593c300d83c76654e92ec76bcea9b858.zip
FreeBSD-src-8707f886593c300d83c76654e92ec76bcea9b858.tar.gz
Import of Heimdal Kerberos from KTH repository circa 2002/09/16.
Diffstat (limited to 'crypto/heimdal/lib/hdb')
-rw-r--r--crypto/heimdal/lib/hdb/common.c45
-rw-r--r--crypto/heimdal/lib/hdb/hdb-ldap.c27
-rw-r--r--crypto/heimdal/lib/hdb/hdb_locl.h8
3 files changed, 15 insertions, 65 deletions
diff --git a/crypto/heimdal/lib/hdb/common.c b/crypto/heimdal/lib/hdb/common.c
index 73bddf2..9375525 100644
--- a/crypto/heimdal/lib/hdb/common.c
+++ b/crypto/heimdal/lib/hdb/common.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997-2002 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -33,35 +33,21 @@
#include "hdb_locl.h"
-RCSID("$Id: common.c,v 1.10 2001/07/13 06:30:41 assar Exp $");
+RCSID("$Id: common.c,v 1.11 2002/09/04 16:32:30 joda Exp $");
int
hdb_principal2key(krb5_context context, krb5_principal p, krb5_data *key)
{
Principal new;
size_t len;
- unsigned char *buf;
int ret;
ret = copy_Principal(p, &new);
- if(ret)
- goto out;
+ if(ret)
+ return ret;
new.name.name_type = 0;
- len = length_Principal(&new);
- buf = malloc(len);
- if(buf == NULL){
- krb5_set_error_string(context, "malloc: out of memory");
- ret = ENOMEM;
- goto out;
- }
- ret = encode_Principal(buf + len - 1, len, &new, &len);
- if(ret){
- free(buf);
- goto out;
- }
- key->data = buf;
- key->length = len;
-out:
+
+ ASN1_MALLOC_ENCODE(Principal, key->data, key->length, &new, &len, ret);
free_Principal(&new);
return ret;
}
@@ -75,24 +61,11 @@ hdb_key2principal(krb5_context context, krb5_data *key, krb5_principal p)
int
hdb_entry2value(krb5_context context, hdb_entry *ent, krb5_data *value)
{
- unsigned char *buf;
size_t len;
int ret;
-
- len = length_hdb_entry(ent);
- buf = malloc(len);
- if(buf == NULL) {
- krb5_set_error_string(context, "malloc: out of memory");
- return ENOMEM;
- }
- ret = encode_hdb_entry(buf + len - 1, len, ent, &len);
- if(ret){
- free(buf);
- return ret;
- }
- value->data = buf;
- value->length = len;
- return 0;
+
+ ASN1_MALLOC_ENCODE(hdb_entry, value->data, value->length, ent, &len, ret);
+ return ret;
}
int
diff --git a/crypto/heimdal/lib/hdb/hdb-ldap.c b/crypto/heimdal/lib/hdb/hdb-ldap.c
index a92285c..8e90798 100644
--- a/crypto/heimdal/lib/hdb/hdb-ldap.c
+++ b/crypto/heimdal/lib/hdb/hdb-ldap.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999 - 2001, PADL Software Pty Ltd.
+ * Copyright (c) 1999-2001, PADL Software Pty Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,7 @@
#include "hdb_locl.h"
-RCSID("$Id: hdb-ldap.c,v 1.9 2001/08/31 18:19:49 joda Exp $");
+RCSID("$Id: hdb-ldap.c,v 1.10 2002/09/04 18:42:22 joda Exp $");
#ifdef OPENLDAP
@@ -451,29 +451,10 @@ LDAP_entry2mods(krb5_context context, HDB * db, hdb_entry * ent,
for (i = 0; i < ent->keys.len; i++) {
unsigned char *buf;
size_t len;
- Key new;
- ret = copy_Key(&ent->keys.val[i], &new);
- if (ret != 0) {
- goto out;
- }
-
- len = length_Key(&new);
- buf = malloc(len);
- if (buf == NULL) {
- krb5_set_error_string(context, "malloc: out of memory");
- ret = ENOMEM;
- free_Key(&new);
+ ASN1_MALLOC_ENCODE(Key, buf, len, &ent->keys.val[i], &len, ret);
+ if (ret != 0)
goto out;
- }
-
- ret = encode_Key(buf + len - 1, len, &new, &len);
- if (ret != 0) {
- free(buf);
- free_Key(&new);
- goto out;
- }
- free_Key(&new);
/* addmod_len _owns_ the key, doesn't need to copy it */
ret = LDAP_addmod_len(&mods, LDAP_MOD_ADD, "krb5Key", buf, len);
diff --git a/crypto/heimdal/lib/hdb/hdb_locl.h b/crypto/heimdal/lib/hdb/hdb_locl.h
index 921eabd..95c7060 100644
--- a/crypto/heimdal/lib/hdb/hdb_locl.h
+++ b/crypto/heimdal/lib/hdb/hdb_locl.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-/* $Id: hdb_locl.h,v 1.17 2001/08/22 20:30:28 assar Exp $ */
+/* $Id: hdb_locl.h,v 1.18 2002/09/10 20:03:48 joda Exp $ */
#ifndef __HDB_LOCL_H__
#define __HDB_LOCL_H__
@@ -56,11 +56,7 @@
#endif
#include <roken.h>
-#ifdef HAVE_OPENSSL
-#include <openssl/des.h>
-#else
-#include <des.h>
-#endif
+#include "crypto-headers.h"
#include <krb5.h>
#include <hdb.h>
#include <hdb-private.h>
OpenPOWER on IntegriCloud