libksba  1.5.0
About: KSBA is a library to make the tasks of working with X.509 certificates, CMS data and related objects more easy.
  Fossies Dox: libksba-1.5.0.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

keyinfo.c File Reference
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "util.h"
#include "asn1-func.h"
#include "keyinfo.h"
#include "shared.h"
#include "convert.h"
#include "ber-help.h"
#include "sexp-parse.h"
#include "stringbuf.h"
#include "der-builder.h"
Include dependency graph for keyinfo.c:

Go to the source code of this file.

Data Structures

struct  algo_table_s
 

Macros

#define SUPPORTED_RSAPSS   2
 
#define TLV_LENGTH(prefix)
 

Enumerations

enum  pkalgo_t {
  PKALGO_NONE, PKALGO_RSA, PKALGO_DSA, PKALGO_ECC,
  PKALGO_X25519, PKALGO_X448, PKALGO_ED25519, PKALGO_ED448
}
 

Functions

static char * get_ecc_curve_oid (const unsigned char *buf, size_t buflen, pkalgo_t *r_pkalgo)
 
static gpg_error_t get_algorithm (int mode, const unsigned char *der, size_t derlen, size_t *r_nread, size_t *r_pos, size_t *r_len, int *r_bitstr, size_t *r_parm_pos, size_t *r_parm_len, int *r_parm_type)
 
gpg_error_t _ksba_parse_algorithm_identifier (const unsigned char *der, size_t derlen, size_t *r_nread, char **r_oid)
 
gpg_error_t _ksba_parse_algorithm_identifier2 (const unsigned char *der, size_t derlen, size_t *r_nread, char **r_oid, char **r_parm, size_t *r_parmlen)
 
gpg_error_t _ksba_keyinfo_to_sexp (const unsigned char *der, size_t derlen, ksba_sexp_t *r_string)
 
static const char * oid_from_buffer (const unsigned char *buf, unsigned int buflen, pkalgo_t *r_pkalgo, int with_sig)
 
gpg_error_t _ksba_keyinfo_from_sexp (ksba_const_sexp_t sexp, int algoinfomode, unsigned char **r_der, size_t *r_derlen)
 
gpg_error_t _ksba_keyinfo_get_pss_info (const unsigned char *der, size_t derlen, char **r_psshash, unsigned int *r_saltlen)
 
static gpg_error_t cryptval_to_sexp (int mode, const unsigned char *der, size_t derlen, const char *keyencralgo, const char *keywrapalgo, const void *encrkey, size_t encrkeylen, ksba_sexp_t *r_string)
 
gpg_error_t _ksba_sigval_to_sexp (const unsigned char *der, size_t derlen, ksba_sexp_t *r_string)
 
gpg_error_t _ksba_encval_to_sexp (const unsigned char *der, size_t derlen, ksba_sexp_t *r_string)
 
gpg_error_t _ksba_encval_kari_to_sexp (const unsigned char *der, size_t derlen, const char *keyencralgo, const char *keywrapalgo, const void *enckey, size_t enckeylen, ksba_sexp_t *r_string)
 

Variables

static const struct algo_table_s pk_algo_table []
 
static const struct algo_table_s sig_algo_table []
 
static const struct algo_table_s enc_algo_table []
 
struct {
   const char *   oid
 
   const char *   name
 
   unsigned char   pkalgo
 
curve_names []
 

Macro Definition Documentation

◆ SUPPORTED_RSAPSS

#define SUPPORTED_RSAPSS   2

Definition at line 81 of file keyinfo.c.

◆ TLV_LENGTH

#define TLV_LENGTH (   prefix)
Value:
do { \
if (!prefix ## len) \
return gpg_error (GPG_ERR_INV_KEYINFO); \
c = *(prefix)++; prefix ## len--; \
if (c == 0x80) \
return gpg_error (GPG_ERR_NOT_DER_ENCODED); \
if (c == 0xff) \
return gpg_error (GPG_ERR_BAD_BER); \
\
if ( !(c & 0x80) ) \
len = c; \
else \
{ \
int count = c & 0x7f; \
\
for (len=0; count; count--) \
{ \
len <<= 8; \
if (!prefix ## len) \
return gpg_error (GPG_ERR_BAD_BER);\
c = *(prefix)++; prefix ## len--; \
len |= c & 0xff; \
} \
} \
if (len > prefix ## len) \
return gpg_error (GPG_ERR_INV_KEYINFO); \
} while (0)
#define gpg_error(a)
Definition: gen-help.h:87

Definition at line 363 of file keyinfo.c.

Enumeration Type Documentation

◆ pkalgo_t

enum pkalgo_t
Enumerator
PKALGO_NONE 
PKALGO_RSA 
PKALGO_DSA 
PKALGO_ECC 
PKALGO_X25519 
PKALGO_X448 
PKALGO_ED25519 
PKALGO_ED448 

Definition at line 52 of file keyinfo.c.

Function Documentation

◆ _ksba_encval_kari_to_sexp()

gpg_error_t _ksba_encval_kari_to_sexp ( const unsigned char *  der,
size_t  derlen,
const char *  keyencralgo,
const char *  keywrapalgo,
const void *  enckey,
size_t  enckeylen,
ksba_sexp_t r_string 
)

Definition at line 1645 of file keyinfo.c.

References cryptval_to_sexp(), gpg_error, tag_info::nhdr, and parse_context_tag.

Referenced by _ksba_cms_get_enc_val().

◆ _ksba_encval_to_sexp()

gpg_error_t _ksba_encval_to_sexp ( const unsigned char *  der,
size_t  derlen,
ksba_sexp_t r_string 
)

Definition at line 1611 of file keyinfo.c.

References cryptval_to_sexp().

Referenced by _ksba_cms_get_enc_val().

◆ _ksba_keyinfo_from_sexp()

◆ _ksba_keyinfo_get_pss_info()

gpg_error_t _ksba_keyinfo_get_pss_info ( const unsigned char *  der,
size_t  derlen,
char **  r_psshash,
unsigned int *  r_saltlen 
)

◆ _ksba_keyinfo_to_sexp()

◆ _ksba_parse_algorithm_identifier()

gpg_error_t _ksba_parse_algorithm_identifier ( const unsigned char *  der,
size_t  derlen,
size_t *  r_nread,
char **  r_oid 
)

◆ _ksba_parse_algorithm_identifier2()

gpg_error_t _ksba_parse_algorithm_identifier2 ( const unsigned char *  der,
size_t  derlen,
size_t *  r_nread,
char **  r_oid,
char **  r_parm,
size_t *  r_parmlen 
)

◆ _ksba_sigval_to_sexp()

gpg_error_t _ksba_sigval_to_sexp ( const unsigned char *  der,
size_t  derlen,
ksba_sexp_t r_string 
)

◆ cryptval_to_sexp()

static gpg_error_t cryptval_to_sexp ( int  mode,
const unsigned char *  der,
size_t  derlen,
const char *  keyencralgo,
const char *  keywrapalgo,
const void *  encrkey,
size_t  encrkeylen,
ksba_sexp_t r_string 
)
static

◆ get_algorithm()

static gpg_error_t get_algorithm ( int  mode,
const unsigned char *  der,
size_t  derlen,
size_t *  r_nread,
size_t *  r_pos,
size_t *  r_len,
int *  r_bitstr,
size_t *  r_parm_pos,
size_t *  r_parm_len,
int *  r_parm_type 
)
static

◆ get_ecc_curve_oid()

static char* get_ecc_curve_oid ( const unsigned char *  buf,
size_t  buflen,
pkalgo_t r_pkalgo 
)
static

Definition at line 398 of file keyinfo.c.

References curve_names, digitp, name, oid, and xtrymalloc.

Referenced by _ksba_keyinfo_from_sexp().

◆ oid_from_buffer()

static const char* oid_from_buffer ( const unsigned char *  buf,
unsigned int  buflen,
pkalgo_t r_pkalgo,
int  with_sig 
)
static

Variable Documentation

◆ 

const { ... } curve_names[]

Referenced by get_ecc_curve_oid().

◆ enc_algo_table

const struct algo_table_s enc_algo_table[]
static
Initial value:
= {
{
"1.2.840.113549.1.1.1",
"\x2A\x86\x48\x86\xF7\x0D\x01\x01\x01", 9,
1, PKALGO_RSA, "rsa", "a", "\x82" },
{
"1.2.840.10045.2.1",
"\x2a\x86\x48\xce\x3d\x02\x01", 7,
1, PKALGO_ECC, "ecdh", "e", "\x80" },
{NULL}
}
@ PKALGO_ECC
Definition: keyinfo.c:57
@ PKALGO_RSA
Definition: keyinfo.c:55

Definition at line 1 of file keyinfo.c.

Referenced by cryptval_to_sexp().

◆ name

const char* name

Definition at line 308 of file keyinfo.c.

Referenced by _ksba_keyinfo_from_sexp(), and get_ecc_curve_oid().

◆ oid

const char* oid

◆ pk_algo_table

const struct algo_table_s pk_algo_table[]
static

Definition at line 1 of file keyinfo.c.

Referenced by _ksba_keyinfo_to_sexp(), and oid_from_buffer().

◆ pkalgo

unsigned char pkalgo

Definition at line 309 of file keyinfo.c.

Referenced by _ksba_keyinfo_from_sexp(), _ksba_keyinfo_to_sexp(), and cryptval_to_sexp().

◆ sig_algo_table

const struct algo_table_s sig_algo_table[]
static

Definition at line 1 of file keyinfo.c.

Referenced by cryptval_to_sexp(), and oid_from_buffer().