Tor  0.4.7.0-alpha-dev
Functions
pem.c File Reference

Implement a trivial version of PEM encoding, for use with NSS. More...

#include "orconfig.h"
#include "lib/encoding/pem.h"
#include "lib/ctime/di_ops.h"
#include "lib/encoding/binascii.h"
#include "lib/log/util_bug.h"
#include "lib/malloc/malloc.h"
#include "lib/string/printf.h"
#include "lib/string/util_string.h"
#include <string.h>

Go to the source code of this file.

Functions

size_t pem_encoded_size (size_t src_len, const char *objtype)
 
int pem_encode (char *dest, size_t destlen, const uint8_t *src, size_t srclen, const char *objtype)
 
int pem_decode (uint8_t *dest, size_t destlen, const char *src, size_t srclen, const char *objtype)
 

Detailed Description

Implement a trivial version of PEM encoding, for use with NSS.

We deliberately do not support any encryption here.

Definition in file pem.c.

Function Documentation

◆ pem_decode()

int pem_decode ( uint8_t *  dest,
size_t  destlen,
const char *  src,
size_t  srclen,
const char *  objtype 
)

Given a PEM-encoded block of size srclen in src, if it has object type objtype, decode it into the destlen-byte buffer at dest. Return the number of characters decoded on success, or -1 on failure.

Definition at line 80 of file pem.c.

◆ pem_encode()

int pem_encode ( char *  dest,
size_t  destlen,
const uint8_t *  src,
size_t  srclen,
const char *  objtype 
)

PEM-encode the srclen-byte object at src into the destlen-byte buffer at dest, tagging it with objtype. Return 0 on success and -1 on failure.

Definition at line 49 of file pem.c.

◆ pem_encoded_size()

size_t pem_encoded_size ( size_t  src_len,
const char *  objtype 
)

Return the length of a src_len-byte object when tagged with objtype and PEM-encoded. Includes terminating NUL.

Definition at line 33 of file pem.c.