OpenVAS Libraries  6.0+beta5
Functions
nasl_signature.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>
#include "system.h"
#include "certificate.h"
#include "nasl_signature.h"
#include "nasl_tree.h"
#include "nasl_var.h"
#include "nasl_func.h"
#include "nasl_lex_ctxt.h"
#include "nasl_debug.h"

Functions

int nasl_verify_signature (const char *filename)
 
char * nasl_extract_signature_fprs (const char *filename)
 Extracts fingerprints of signing public keys in a given signature file. More...
 
char * nasl_get_pubkey (gpgme_ctx_t ctx, char *fingerprint)
 Reads in a full public key. The returned string will be ascii- armored. More...
 
GSList * nasl_get_all_certificates ()
 Creates certificate_ts for all certificates found in the. More...
 

Function Documentation

char* nasl_extract_signature_fprs ( const char *  filename)

Extracts fingerprints of signing public keys in a given signature file.

Works like nasl_verify_signature, but always returns a string with the fingerprints in it (NULL if error), even if the keys are not trusted.

Parameters
filenamePath to the signed file (e.g. /../check_killerapp.nasl).
Returns
A string with comma- separated fingerprints or NULL if error.
See Also
nasl_verify_signature( const char* filename )
Todo:
Once there was a size limitation for the cache. It was removed since OpenVAS > 2.0 and this fixed size here should eventually be replaced by dynamic solution.
GSList* nasl_get_all_certificates ( )

Creates certificate_ts for all certificates found in the.

(custom) gpg home directory and returns a pointer to a GSList containing (pointers to) them.

Creation has to be done in two steps: First retrieve info like ownername and trust level and then read in the full public key. The two steps have to be done seperately because the two gpgme listing operations are exclusive.

Returns
Pointer to a GSList containing pointers to certificate structs.
Todo:
consider using the certificates_t type from base/certificates.c
Todo:
base/certificate.c offers certificates (list) functionality
char* nasl_get_pubkey ( gpgme_ctx_t  ctx,
char *  fingerprint 
)

Reads in a full public key. The returned string will be ascii- armored.

Parameters
ctxThe gpgme context to work in.
fingerprintFingerprint of the key to return.
Returns
The public key belonging to fingerprint in an g_malloc'ed string or NULL if an error occurred.
int nasl_verify_signature ( const char *  filename)

Checks the detached OpenPGP signature of the file given by FILENAME. The name of the signature file is derived from FILENAME by appending ".asc".

If a signature file exists and it contains only fully valid signatures, the function returns 0. If any of the signatures is not valid or was made by an unknown or untrusted key, the function returns 1. If an error occurs or the file does not have a corresponding detached signature the function returns -1.

Parameters
filenameFilename (e.g. 1.txt) for which to check signature (e.g. 1.txt.asc).
Returns
Zero, if files exists and all signatures are fully trusted. 1 if at least one signature from invalid or untrusted key. -1 on missing file or error.