Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:48:45 2009

## Asterisk developer's documentation

# cryptostub.c File Reference

`#include <unistd.h>`
`#include <stdlib.h>`
`#include "asterisk/crypto.h"`
`#include "asterisk/logger.h"`

Include dependency graph for cryptostub.c:

Go to the source code of this file.

## Functions

static int | stub_ast_check_signature (struct ast_key *key, const char *msg, const char *sig)
static int | stub_ast_check_signature_bin (struct ast_key *key, const char *msg, int msglen, const unsigned char *sig)
static int | stub_ast_encdec_bin (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)
static struct ast_key * | stub_ast_key_get (const char *kname, int ktype)
static int | stub_ast_sign (struct ast_key *key, char *msg, char *sig)
static int | stub_ast_sign_bin (struct ast_key *key, const char *msg, int msglen, unsigned char *sig)

## Variables

int(* | ast_check_signature )(struct ast_key *key, const char *msg, const char *sig)
| Check the authenticity of a message signature using a given public key.
int(* | ast_check_signature_bin )(struct ast_key *key, const char *msg, int msglen, const unsigned char *sig)
| Check the authenticity of a message signature using a given public key.
int(* | ast_decrypt_bin )(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)
int(* | ast_encrypt_bin )(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)
struct ast_key *(* | ast_key_get )(const char *key, int type)
| Retrieve a key.
int(* | ast_sign )(struct ast_key *key, char *msg, char *sig)
int(* | ast_sign_bin )(struct ast_key *key, const char *msg, int msglen, unsigned char *sig)

## Function Documentation

static int stub_ast_check_signature | ( | struct ast_key * | key,
|  | const char * | msg,
|  | const char * | sig |
| ) |  |  | `[static]`

Definition at line 35 of file cryptostub.c.

References ast_log(), and LOG_NOTICE.

    00036 {
    00037    ast_log(LOG_NOTICE, "Crypto support not loaded!\n");
    00038    return -1;
    00039 }

static int stub_ast_check_signature_bin | ( | struct ast_key * | key,
|  | const char * | msg,
|  | int | msglen,
|  | const unsigned char * | sig |
| ) |  |  | `[static]`

Definition at line 41 of file cryptostub.c.

References ast_log(), and LOG_NOTICE.

    00042 {
    00043    ast_log(LOG_NOTICE, "Crypto support not loaded!\n");
    00044    return -1;
    00045 }

static int stub_ast_encdec_bin | ( | unsigned char * | dst,
|  | const unsigned char * | src,
|  | int | srclen,
|  | struct ast_key * | key |
| ) |  |  | `[static]`

Definition at line 59 of file cryptostub.c.

References ast_log(), and LOG_NOTICE.

    00060 {
    00061    ast_log(LOG_NOTICE, "Crypto support not loaded!\n");
    00062    return -1;
    00063 }

static struct ast_key* stub_ast_key_get | ( | const char * | kname,
|  | int | ktype |
| ) |  |  | `[static, read]`

Definition at line 29 of file cryptostub.c.

References ast_log(), and LOG_NOTICE.

    00030 {
    00031    ast_log(LOG_NOTICE, "Crypto support not loaded!\n");
    00032    return NULL;
    00033 }

static int stub_ast_sign | ( | struct ast_key * | key,
|  | char * | msg,
|  | char * | sig |
| ) |  |  | `[static]`

Definition at line 47 of file cryptostub.c.

References ast_log(), and LOG_NOTICE.

    00048 {
    00049    ast_log(LOG_NOTICE, "Crypto support not loaded!\n");
    00050    return -1;
    00051 }

static int stub_ast_sign_bin | ( | struct ast_key * | key,
|  | const char * | msg,
|  | int | msglen,
|  | unsigned char * | sig |
| ) |  |  | `[static]`

Definition at line 53 of file cryptostub.c.

References ast_log(), and LOG_NOTICE.

    00054 {
    00055    ast_log(LOG_NOTICE, "Crypto support not loaded!\n");
    00056    return -1;
    00057 }

## Variable Documentation

int(* ast_check_signature)(struct ast_key *key, const char *msg, const char *sig)

Initial value:

       stub_ast_check_signature

Check the authenticity of a message signature using a given public key.

Parameters:

  | key | a public key to use to verify
  | msg | the message that has been signed
  | sig | the proposed valid signature in mime64-like encoding

Returns 0 if the signature is valid, or -1 otherwise

Referenced by authenticate_verify(), crypto_init(), and register_verify().

int(* ast_check_signature_bin)(struct ast_key *key, const char *msg, int msglen, const unsigned char *sig)

Initial value:

       stub_ast_check_signature_bin

Check the authenticity of a message signature using a given public key.

Parameters:

  | key | a public key to use to verify
  | msg | the message that has been signed
  | sig | the proposed valid signature in raw binary representation

Returns 0 if the signature is valid, or -1 otherwise

Referenced by __ast_check_signature(), check_key(), and crypto_init().

int(* ast_decrypt_bin)(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)

Initial value:

       stub_ast_encdec_bin

Parameters:

  | key | a private key to use to decrypt
  | src | the message to decrypt
  | srclen | the length of the message to decrypt
  | dst | a pointer to a buffer of at least srclen bytes in which the decrypted answer will be stored

Returns length of decrypted data on success or -1 on failure.

Referenced by check_key(), and crypto_init().

int(* ast_encrypt_bin)(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)

Initial value:

       stub_ast_encdec_bin

Parameters:

  | key | a private key to use to encrypt
  | src | the message to encrypt
  | srclen | the length of the message to encrypt
  | dst | a pointer to a buffer of at least srclen * 1.5 bytes in which the encrypted answer will be stored

Returns length of encrypted data on success or -1 on failure.

Referenced by crypto_init(), and update_key().

struct ast_key*(* ast_key_get)(const char *key, int type)

Initial value:

       stub_ast_key_get

Retrieve a key.

Parameters:

  | name | of the key we are retrieving
  | int | type of key (AST_KEY_PUBLIC or AST_KEY_PRIVATE)

Returns the key on success or NULL on failure

Referenced by authenticate(), authenticate_verify(), check_key(), crypto_init(), register_verify(), and update_key().

int(* ast_sign)(struct ast_key *key, char *msg, char *sig)

Initial value:

       stub_ast_sign

Parameters:

  | key | a private key to use to create the signature
  | msg | the message to sign
  | sig | a pointer to a buffer of at least 256 bytes in which the mime64-like encoded signature will be stored

Returns 0 on success or -1 on failure.

Referenced by authenticate(), and crypto_init().

int(* ast_sign_bin)(struct ast_key *key, const char *msg, int msglen, unsigned char *sig)

Initial value:

       stub_ast_sign_bin

Parameters:

  | key | a private key to use to create the signature
  | msg | the message to sign
  | sig | a pointer to a buffer of at least 128 bytes in which the raw encoded signature will be stored

Returns 0 on success or -1 on failure.

Referenced by __ast_sign(), crypto_init(), and update_key().