src/internal_format.h
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 04 Jun 2020 11:18:45 +0200
changeset 4729 3df9a2a67597
parent 4639 09116d12e937
child 4792 7056435ab9e7
child 5246 67016f508d40
permissions -rw-r--r--
forgot test files
vb@4625
     1
// This file is under GNU General Public License 3.0
vb@4625
     2
// see LICENSE.txt
vb@4625
     3
vb@4625
     4
#pragma once
vb@4625
     5
vb@4625
     6
#include "message.h"
vb@4625
     7
#include "cryptotech.h"
vb@4625
     8
vb@4625
     9
#ifdef __cplusplus
vb@4625
    10
extern "C" {
vb@4625
    11
#endif
vb@4625
    12
vb@4625
    13
// encode_internal() - encode to the internal message format
vb@4625
    14
//
vb@4625
    15
//  parameters:
vb@4625
    16
//      value (in)          blob
vb@4625
    17
//      size (in)           size of value
vb@4625
    18
//      mime_type (in)      string of MIME type
vb@4625
    19
//      code (out)          blob in Internal Message Format
vb@4625
    20
//      code_size (out)     size of code
vb@4625
    21
//
vb@4625
    22
//  caveat:
vb@4625
    23
//      call this for the data in an attachment
vb@4625
    24
//
vb@4625
    25
//      for unsupported MIME types this function is returning NULL for code and
vb@4625
    26
//      does not fail
vb@4625
    27
//
vb@4625
    28
//      for supported MIME types this function is creating the internal message
vb@4625
    29
//      format by copying the data in value
vb@4625
    30
//
vb@4625
    31
//      code goes into the ownership of the caller
vb@4625
    32
//
vb@4625
    33
//  see also:
vb@4625
    34
//      https://dev.pep.foundation/Engine/ElevatedAttachments
vb@4625
    35
vb@4625
    36
DYNAMIC_API PEP_STATUS encode_internal(
vb@4625
    37
        const char *value,
vb@4625
    38
        size_t size,
vb@4625
    39
        const char *mime_type,
vb@4625
    40
        char **code,
vb@4625
    41
        size_t *code_size
vb@4625
    42
    );
vb@4625
    43
vb@4625
    44
vb@4625
    45
// decode_internal() - decode from internal message format
vb@4625
    46
//
vb@4625
    47
//  parameters:
vb@4625
    48
//      code (in)           blob in Internal Message Format
vb@4625
    49
//      code_size (in)      size of code
vb@4625
    50
//      tech (in)           crypto tech for MIME type, PEP_crypt_none for auto
vb@4625
    51
//      value (out)         blob or string for longmsg
vb@4625
    52
//      size (out)          size of value
vb@4625
    53
//      mime_type (out)     string with MIME type or NULL for longmsg
vb@4625
    54
//
vb@4625
    55
//  caveat:
vb@4625
    56
//      this functions copies data from the code
vb@4625
    57
//
vb@4625
    58
//      value goes into the ownership of the caller
vb@4625
    59
//      mime_type goes into the ownership of the caller
vb@4625
    60
vb@4625
    61
DYNAMIC_API PEP_STATUS decode_internal(
vb@4625
    62
        const char *code,
vb@4625
    63
        size_t code_size,
vb@4625
    64
        char **value,
vb@4625
    65
        size_t *size,
vb@4625
    66
        char **mime_type
vb@4625
    67
    );
vb@4625
    68
vb@4625
    69
vb@4625
    70
#ifdef __cplusplus
vb@4625
    71
}
vb@4625
    72
#endif