case CDK_Error_No_Key: return GNUTLS_E_OPENPGP_GETKEY_FAILED;
case CDK_Wrong_Format: return GNUTLS_E_OPENPGP_TRUSTDB_VERSION_UNSUPPORTED;
case CDK_Armor_Error: return GNUTLS_E_ASCII_ARMOR_ERROR;
- case CDK_Inv_Value: return GNUTLS_E_INVALID_VALUE;
+ case CDK_Inv_Value: return GNUTLS_E_INVALID_REQUEST;
}
return rc;
}
{
keybox_blob *c;
- if( !r_ctx )
- return GNUTLS_E_INVALID_VALUE;
+ if( !r_ctx ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
c = cdk_calloc( 1, sizeof * c );
if( !c ) {
CDK_KEYDB_HD hd;
int rc;
- if( !blob )
+ if( !blob ) {
+ gnutls_assert( );
return NULL;
+ }
switch( blob->type ) {
case KBX_BLOB_FILE:
- rc = cdk_keydb_new( &hd, blob->armored?CDK_DBTYPE_ARMORED:
+ rc = cdk_keydb_new( &hd, blob->armored? CDK_DBTYPE_ARMORED:
CDK_DBTYPE_KEYRING, blob->data, blob->size );
break;
default:
rc = -1;
+ gnutls_assert( );
break;
}
if( rc )
keybox_blob *blob = NULL;
int rc;
- if( !keyring || !keyring->data || pos > keyring->size )
+ if( !keyring || !keyring->data || pos > keyring->size ) {
+ gnutls_assert( );
return NULL;
+ }
rc = kbx_blob_new( &blob );
if( rc )
uint8 buf[4096];
int rc = 0, nread;
- if( !knode || !raw )
- return GNUTLS_E_INVALID_VALUE;
+ if( !knode || !raw ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
while( (node = cdk_kbnode_walk( knode, &ctx, 0 )) ) {
pkt = cdk_kbnode_get_packet( node );
CDK_KBNODE knode;
int rc;
- if( !raw || !r_knode )
- return GNUTLS_E_INVALID_VALUE;
+ if( !raw || !r_knode ) {
+ return GNUTLS_E_INVALID_REQUEST;
+ gnutls_assert( );
+ }
s = cdk_stream_tmp( );
if( !s ) {
uint8 buf[4096];
int rc = 0, nread, nbytes = 0;
- if( !buf || !raw )
- return GNUTLS_E_INVALID_VALUE;
+ if( !buf || !raw ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
cdk_stream_seek( inp, 0 );
while( !cdk_stream_eof( inp ) ) {
int algo, i;
int rc = 0;
- if( !cert || !pk )
- return GNUTLS_E_INVALID_VALUE;
+ if( !cert || !pk ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
/* GnuTLS OpenPGP doesn't support ELG keys */
if( is_ELG(pk->pubkey_algo) )
uint8 buf[4096];
int rc, nread;
- if( !cert || !sig )
- return GNUTLS_E_INVALID_VALUE;
+ if( !cert || !sig ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
tmp = cdk_stream_tmp( );
if( !tmp ) {
uint8 buf[512];
int rc = 0;
- if( !pkey || raw_key->size <= 0 )
- return GNUTLS_E_INVALID_VALUE;
+ if( !pkey || raw_key->size <= 0 ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
out = cdk_stream_tmp( );
if( !out )
CDK_PACKET *pkt = NULL;
int rc;
- if( !cert )
- return GNUTLS_E_INVALID_VALUE;
+ if( !cert ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
memset( cert, 0, sizeof *cert );
void * desc;
int rc = 0;
- if( !key || !keyring || by == KEY_ATTR_NONE )
- return GNUTLS_E_INVALID_VALUE;
+ if( !key || !keyring || by == KEY_ATTR_NONE ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
memset( key, 0, sizeof *key );
blob = kbx_read_blob( keyring, 0 );
int i = 0;
int rc = 0;
- if ( !res || !key || !cert )
- return GNUTLS_E_INVALID_VALUE;
+ if ( !res || !key || !cert ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
rc = datum_to_kbnode( cert, &knode );
if ( rc )
if( !res || !KEYFILE || !CERTFILE ) {
gnutls_assert();
- return GNUTLS_E_INVALID_VALUE;
+ return GNUTLS_E_INVALID_REQUEST;
}
if( stat( CERTFILE, &statbuf ) || stat( KEYFILE, &statbuf ) ) {
if( cert == NULL )
return 0;
- if( datum_to_kbnode( cert, &knode ) )
+ if( datum_to_kbnode( cert, &knode ) ) {
+ gnutls_assert();
return 0;
+ }
while( (p = cdk_kbnode_walk( knode, &ctx, 0 )) ) {
pkt = cdk_kbnode_get_packet( p );
if( pkt->pkttype == CDK_PKT_USER_ID )
size_t size = 0;
int rc = 0;
- if( !cert || !dn )
- return GNUTLS_E_INVALID_VALUE;
+ printf ("** cert=%p nnames=%d\n", cert,
+ gnutls_openpgp_count_key_names( cert ) );
+ if( !cert || !dn ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
if( idx < 0 || idx > gnutls_openpgp_count_key_names( cert ) )
return GNUTLS_E_INTERNAL_ERROR;
int flags = 0, ot = 0;
int rc = 0;
- if( !trustdb || !key || !r_trustval )
- return GNUTLS_E_INVALID_VALUE;
+ if( !trustdb || !key || !r_trustval ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
*r_trustval = 0;
if( !cert_list || cert_list_length != 1 || !keyring )
return GNUTLS_E_NO_CERTIFICATE_FOUND;
- if( !keyring->size && !trustdb )
- return GNUTLS_E_INVALID_VALUE;
+ if( !keyring->size && !trustdb ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
blob = kbx_read_blob( keyring, 0 );
if( !blob )
CDK_PACKET *pkt;
cdkPKT_public_key *pk = NULL;
- if( !cert || !fpr || !fprlen )
- return GNUTLS_E_INVALID_VALUE;
+ if( !cert || !fpr || !fprlen ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
*fprlen = 0;
cdkPKT_public_key *pk = NULL;
unsigned long kid[2];
- if( !cert || !keyid )
- return GNUTLS_E_INVALID_VALUE;
+ if( !cert || !keyid ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
pkt = search_packet( cert, CDK_PKT_PUBLIC_KEY );
if( !pkt )
int enc = 0;
int rc = 0;
- if( !keyring || !name )
- return GNUTLS_E_INVALID_VALUE;
+ if( !keyring || !name ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
rc = cdk_stream_open( name, &inp );
if( rc )
uint8 *blob;
size_t nbytes = 0;
- if( !keyring || !data || !len )
- return GNUTLS_E_INVALID_VALUE;
+ if( !keyring || !data || !len ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
blob = kbx_data_to_keyring( KBX_BLOB_DATA, 0, data, len, &nbytes );
if( blob && nbytes ) {
{
struct stat statbuf;
- if( !c || !file )
- return GNUTLS_E_INVALID_VALUE;
+ if( !c || !file ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
if( stat( file, &statbuf ) )
return GNUTLS_E_FILE_ERROR;
uint8 *buf;
int rc = 0;
- if( !c || !data || !dlen )
- return GNUTLS_E_INVALID_VALUE;
+ if( !c || !data || !dlen ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
inp = cdk_stream_tmp_from_mem( data, dlen );
if( !inp )
int rc = 0, state = 0, nread = 0;
size_t nbytes = 0, n = 0;
- if ( !host || !key )
- return GNUTLS_E_INVALID_VALUE;
+ if ( !host || !key ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
if( !port )
port = 11371; /* standard service port */
uint32 keyid;
int rc = 0;
- if( !ret || !cred || !key_fpr )
- return GNUTLS_E_INVALID_VALUE;
-
+ if( !ret || !cred || !key_fpr ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if( key_fpr_size != 16 && key_fpr_size != 20 )
return GNUTLS_E_HASH_FAILED; /* only MD5 and SHA1 are supported */
char* keyserver,
int port)
{
- if ( !res || !keyserver )
- return GNUTLS_E_INVALID_VALUE;
+ if ( !res || !keyserver ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
if( !port )
port = 11371;
static int
xml_add_tag( gnutls_string *xmlkey, const char *tag, const char *val )
{
- if( !xmlkey || !tag || !val )
- return GNUTLS_E_INVALID_VALUE;
+ if( !xmlkey || !tag || !val ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
_gnutls_string_append_str( xmlkey, " <" );
_gnutls_string_append_str( xmlkey, tag );
size_t i;
int rc = 0;
- if( !xmlkey || !data || !tag )
- return GNUTLS_E_INVALID_VALUE;
+ if( !xmlkey || !data || !tag ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
p = gnutls_calloc( 1, 2 * ( count + 3 ) );
if( !p ) {
const char *s = " <KEY ENCODING=\"HEX\"/>\n";
int rc = 0;
- if( !xmlkey || !pk )
- return GNUTLS_E_INVALID_VALUE;
+ if( !xmlkey || !pk ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
_gnutls_string_append_str( xmlkey, s );
unsigned long kid[2];
int i = 0, rc = 0;
- if( !xmlkey || !pk )
- return GNUTLS_E_INVALID_VALUE;
+ if( !xmlkey || !pk ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
s = sub? " <SUBKEY>\n" : " <MAINKEY>\n";
_gnutls_string_append_str( xmlkey, s );
char *p, *name, tmp[32];
int rc = 0;
- if ( !xmlkey || !dn || !id )
- return GNUTLS_E_INVALID_VALUE;
+ if ( !xmlkey || !dn || !id ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
s = " <USERID>\n";
_gnutls_string_append_str( xmlkey, s );
unsigned long kid[2];
int rc = 0;
- if( !xmlkey || !sig )
- return GNUTLS_E_INVALID_VALUE;
+ if( !xmlkey || !sig ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
s = " <SIGNATURE>\n";
_gnutls_string_append_str( xmlkey, s );
int idx = 0, rc = 0;
gnutls_string string_xml_key;
- if( !cert || !xmlkey )
- return GNUTLS_E_INVALID_VALUE;
+ if( !cert || !xmlkey ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
rc = datum_to_kbnode( cert, &knode );
if( rc )
gnutls_certificate_set_openpgp_trustdb( gnutls_certificate_credentials res,
char* trustdb )
{
- if( !res || !trustdb )
- return GNUTLS_E_INVALID_VALUE;
+ if( !res || !trustdb ) {
+ gnutls_assert( );
+ return GNUTLS_E_INVALID_REQUEST;
+ }
/* the old v2 format was used with 1.0.6, do we still need to check
it now because GPG 1.0.7, 1.2.0, 1.21 and even 1.3.0 is out? */