[gnutls-dev] security/gnutls does not build
Mikhail Teterin
mi+mx@aldan.algebra.com
Tue Sep 30 13:51:02 2003
--Boundary-00=_MD2c/NMo5NcGdpY
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Apparently, gnutls was not prepared for the changes, that are in the new
OpenCDK-0.5.1... Attached is the lengthy patch, which adapts to the new
API. Not that it changed much -- mostly the data-types renaming and some
symbols obsoleted before finaly removed. Please, permit commit.
Thanks,
-mi
P.S. The software still generates some warnings -- including value-less
returns in non-void functions. Scary for a security-related package...
--Boundary-00=_MD2c/NMo5NcGdpY
Content-Type: text/x-diff;
charset="us-ascii";
name="patch-opencdk"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="patch-opencdk"
--- libextra/gnutls_openpgp.c Sat May 3 05:05:54 2003
+++ libextra/gnutls_openpgp.c Thu Sep 25 17:23:38 2003
@@ -131,10 +131,10 @@
}
-static CDK_KEYDB_HD
+static cdk_keydb_hd_t
kbx_to_keydb( keybox_blob *blob )
{
- CDK_KEYDB_HD hd;
+ cdk_keydb_hd_t hd;
int rc;
if( !blob ) {
@@ -144,8 +144,7 @@
switch( blob->type ) {
case KBX_BLOB_FILE:
- rc = cdk_keydb_new( &hd, blob->armored? CDK_DBTYPE_ARMORED:
- CDK_DBTYPE_KEYRING, blob->data, blob->size );
+ rc = cdk_keydb_new(&hd, CDK_DBTYPE_PK_KEYRING, blob->data, blob->size);
break;
case KBX_BLOB_DATA:
@@ -236,7 +235,7 @@
CDK_PACKET*
search_packet( const gnutls_datum *buf, int pkttype )
{
- static CDK_KBNODE knode = NULL;
+ static cdk_kbnode_t knode = NULL;
CDK_PACKET *pkt;
if( !buf && !pkttype ) {
@@ -253,7 +252,7 @@
static int
-stream_to_datum( CDK_STREAM inp, gnutls_datum *raw )
+stream_to_datum( cdk_stream_t inp, gnutls_datum *raw )
{
uint8 buf[4096];
int rc = 0, nread, nbytes = 0;
@@ -280,7 +279,7 @@
static int
-openpgp_pk_to_gnutls_cert( gnutls_cert *cert, cdkPKT_public_key *pk )
+openpgp_pk_to_gnutls_cert( gnutls_cert *cert, cdk_pkt_pubkey_t pk )
{
uint8 buf[512];
size_t nbytes = 0;
@@ -331,9 +330,9 @@
static int
-openpgp_sig_to_gnutls_cert( gnutls_cert *cert, cdkPKT_signature *sig )
+openpgp_sig_to_gnutls_cert( gnutls_cert *cert, cdk_pkt_signature_t sig )
{
- CDK_STREAM tmp;
+ cdk_stream_t tmp;
CDK_PACKET pkt;
uint8 buf[4096];
int rc, nread;
@@ -352,7 +351,7 @@
memset( &pkt, 0, sizeof pkt );
pkt.pkttype = CDK_PKT_SIGNATURE;
pkt.pkt.signature = sig;
- rc = cdk_pkt_build( tmp, &pkt );
+ rc = cdk_pkt_write( tmp, &pkt );
if( !rc ) {
cdk_stream_seek( tmp, 0 );
nread = cdk_stream_read( tmp, buf, 4095 );
@@ -384,10 +383,10 @@
_gnutls_openpgp_key2gnutls_key( gnutls_private_key *pkey,
gnutls_datum *raw_key )
{
- CDK_KBNODE snode;
+ cdk_kbnode_t snode;
CDK_PACKET *pkt;
- CDK_STREAM out;
- cdkPKT_secret_key *sk = NULL;
+ cdk_stream_t out;
+ cdk_pkt_seckey_t sk = NULL;
int pke_algo, i, j;
size_t nbytes = 0;
uint8 buf[512];
@@ -470,7 +469,7 @@
int
_gnutls_openpgp_cert2gnutls_cert( gnutls_cert *cert, gnutls_datum raw )
{
- CDK_KBNODE knode = NULL;
+ cdk_kbnode_t knode = NULL;
CDK_PACKET *pkt = NULL;
int rc;
@@ -512,8 +511,7 @@
{
keybox_blob *blob = NULL;
CDK_KEYDB_HD hd = NULL;
- CDK_KBNODE knode = NULL;
- CDK_DBSEARCH ks = NULL;
+ cdk_kbnode_t knode = NULL;
unsigned long keyid[2];
unsigned char *buf;
void * desc;
@@ -542,13 +540,13 @@
}
else
desc = pattern;
- rc = cdk_keydb_search_new( &ks, by, desc );
+ rc = cdk_keydb_search_start(hd, by, desc );
if( rc ) {
rc = map_cdk_rc( rc );
goto leave;
}
- rc = cdk_keydb_search( hd, ks, &knode );
+ rc = cdk_keydb_search( hd, &knode );
if( rc ) {
rc = map_cdk_rc( rc );
goto leave;
@@ -569,7 +567,6 @@
leave:
cdk_free( hd );
cdk_kbnode_release( knode );
- cdk_keydb_search_free( ks );
kbx_blob_release( blob );
return rc;
}
@@ -581,7 +578,7 @@
gnutls_datum *key )
{
gnutls_datum raw;
- CDK_KBNODE knode = NULL, ctx = NULL, p;
+ cdk_kbnode_t knode = NULL, ctx = NULL, p;
CDK_PACKET *pkt;
int i = 0;
int rc = 0;
@@ -623,7 +620,7 @@
break;
if( pkt->pkttype == CDK_PKT_PUBLIC_KEY ) {
int n = res->ncerts;
- cdkPKT_public_key *pk = pkt->pkt.public_key;
+ cdk_pkt_pubkey_t pk = pkt->pkt.public_key;
res->cert_list_length[n] = 1;
if (_gnutls_set_datum( &res->cert_list[n][0].raw,
cert->data, cert->size ) < 0) {
@@ -635,7 +632,7 @@
}
else if( pkt->pkttype == CDK_PKT_SIGNATURE ) {
int n = res->ncerts;
- cdkPKT_signature *sig = pkt->pkt.signature;
+ cdk_pkt_signature_t sig = pkt->pkt.signature;
openpgp_sig_to_gnutls_cert( &res->cert_list[n][0], sig );
}
}
@@ -679,8 +676,8 @@
char* KEYFILE )
{
struct stat statbuf;
- CDK_STREAM inp = NULL;
- CDK_KBNODE knode = NULL, ctx = NULL, p;
+ cdk_stream_t inp = NULL;
+ cdk_kbnode_t knode = NULL, ctx = NULL, p;
CDK_PACKET *pkt = NULL;
gnutls_datum raw;
int i = 0, n;
@@ -734,7 +731,7 @@
pkt = cdk_kbnode_get_packet( p );
if( pkt->pkttype == CDK_PKT_PUBLIC_KEY ) {
int n = res->ncerts;
- cdkPKT_public_key *pk = pkt->pkt.public_key;
+ cdk_pkt_pubkey_t pk = pkt->pkt.public_key;
res->cert_list_length[n] = 1;
stream_to_datum( inp, &res->cert_list[n][0].raw );
openpgp_pk_to_gnutls_cert( &res->cert_list[n][0], pk );
@@ -742,7 +739,7 @@
}
else if( pkt->pkttype == CDK_PKT_SIGNATURE ) {
int n = res->ncerts;
- cdkPKT_signature *sig = pkt->pkt.signature;
+ cdk_pkt_signature_t sig = pkt->pkt.signature;
openpgp_sig_to_gnutls_cert( &res->cert_list[n][0], sig );
}
}
@@ -790,7 +787,7 @@
int
gnutls_openpgp_count_key_names( const gnutls_datum *cert )
{
- CDK_KBNODE knode, p, ctx = NULL;
+ cdk_kbnode_t knode, p, ctx = NULL;
CDK_PACKET *pkt;
int nuids = 0;
@@ -825,9 +822,9 @@
int idx,
gnutls_openpgp_name *dn )
{
- CDK_KBNODE knode = NULL, ctx = NULL, p;
+ cdk_kbnode_t knode = NULL, ctx = NULL, p;
CDK_PACKET *pkt = NULL;
- cdkPKT_user_id *uid = NULL;
+ cdk_pkt_userid_t uid = NULL;
char *email;
int pos = 0, pos1 = 0, pos2 = 0;
size_t size = 0;
@@ -908,11 +905,10 @@
int idx,
char *buf, unsigned int sizeof_buf)
{
- CDK_KBNODE knode = NULL, ctx = NULL, p;
+ cdk_kbnode_t knode = NULL, ctx = NULL, p;
CDK_PACKET *pkt = NULL;
- cdkPKT_user_id *uid = NULL;
- char *email;
- int pos = 0, pos1 = 0, pos2 = 0;
+ cdk_pkt_userid_t uid = NULL;
+ int pos = 0;
size_t size = 0;
int rc = 0;
@@ -1092,10 +1088,10 @@
const gnutls_datum *key,
int *r_trustval )
{
- CDK_KBNODE knode = NULL;
- CDK_STREAM inp;
+ cdk_kbnode_t knode = NULL;
+ cdk_stream_t inp;
CDK_PACKET *pkt;
- cdkPKT_public_key *pk = NULL;
+ cdk_pkt_pubkey_t pk = NULL;
int flags = 0, ot = 0;
int rc = 0;
@@ -1188,7 +1184,7 @@
const gnutls_datum* cert_list,
int cert_list_length )
{
- CDK_KBNODE knode = NULL;
+ cdk_kbnode_t knode = NULL;
CDK_KEYDB_HD hd = NULL;
keybox_blob *blob = NULL;
int rc = 0;
@@ -1228,7 +1224,7 @@
return GNUTLS_CERT_INVALID | GNUTLS_CERT_NOT_TRUSTED;
}
- rc = cdk_key_check_sigs( knode, hd, &status );
+ rc = cdk_pk_check_sigs( knode, hd, &status );
if( rc == CDK_Error_No_Key )
rc = 0; /* fixme */
@@ -1266,7 +1262,7 @@
unsigned char *fpr, size_t *fprlen )
{
CDK_PACKET *pkt;
- cdkPKT_public_key *pk = NULL;
+ cdk_pkt_pubkey_t pk = NULL;
if( !cert || !fpr || !fprlen ) {
gnutls_assert( );
@@ -1302,7 +1298,7 @@
unsigned char keyid[8] )
{
CDK_PACKET *pkt;
- cdkPKT_public_key *pk = NULL;
+ cdk_pkt_pubkey_t pk = NULL;
unsigned long kid[2];
if( !cert || !keyid ) {
@@ -1342,7 +1338,7 @@
int
gnutls_openpgp_add_keyring_file(gnutls_datum *keyring, const char *name)
{
- CDK_STREAM inp = NULL;
+ cdk_stream_t inp = NULL;
uint8 *blob;
size_t nbytes;
int enc = 0;
@@ -1438,7 +1434,7 @@
gnutls_certificate_set_openpgp_keyring_mem( gnutls_certificate_credentials c,
const opaque *data, size_t dlen )
{
- CDK_STREAM inp;
+ cdk_stream_t inp;
size_t count;
uint8 *buf;
int rc = 0;
@@ -1609,7 +1605,7 @@
static int
-xml_add_mpi( gnutls_string *xmlkey, cdkPKT_public_key *pk, int idx,
+xml_add_mpi( gnutls_string *xmlkey, cdk_pkt_pubkey_t pk, int idx,
const char *tag )
{
uint8 buf[4096];
@@ -1623,7 +1619,7 @@
static int
-xml_add_key_mpi( gnutls_string *xmlkey, cdkPKT_public_key *pk )
+xml_add_key_mpi( gnutls_string *xmlkey, cdk_pkt_pubkey_t pk )
{
const char *s = " <KEY ENCODING=\"HEX\"/>\n";
int rc = 0;
@@ -1664,7 +1660,7 @@
static int
-xml_add_key( gnutls_string *xmlkey, int ext, cdkPKT_public_key *pk, int sub )
+xml_add_key( gnutls_string *xmlkey, int ext, cdk_pkt_pubkey_t pk, int sub )
{
const char *algo, *s;
char keyid[16], fpr[41], tmp[32];
@@ -1742,7 +1738,7 @@
static int
xml_add_userid( gnutls_string *xmlkey, int ext,
- gnutls_openpgp_name *dn, cdkPKT_user_id *id )
+ gnutls_openpgp_name *dn, cdk_pkt_userid_t id )
{
const char *s;
char *p, *name, tmp[32];
@@ -1799,7 +1795,7 @@
static int
-xml_add_sig( gnutls_string *xmlkey, int ext, cdkPKT_signature *sig )
+xml_add_sig( gnutls_string *xmlkey, int ext, cdk_pkt_signature_t sig )
{
const char *algo, *s;
char tmp[32], keyid[16];
@@ -1887,7 +1883,7 @@
gnutls_openpgp_key_to_xml( const gnutls_datum *cert,
gnutls_datum *xmlkey, int ext )
{
- CDK_KBNODE knode, node, ctx = NULL;
+ cdk_kbnode_t knode, node, ctx = NULL;
CDK_PACKET *pkt;
gnutls_openpgp_name dn;
const char *s;
--- src/serv.c Sat May 3 12:29:14 2003
+++ src/serv.c Thu Sep 25 17:25:31 2003
@@ -1106,7 +1106,7 @@
static const char *hostname = "hkp://wwwkeys.pgp.net";
static const short port = 11371;
int rc;
- CDK_KBNODE knode = NULL;
+ cdk_kbnode_t knode = NULL;
unsigned int i;
fprintf(stderr, "must recv: ");
--Boundary-00=_MD2c/NMo5NcGdpY--