supercop

Basic CLI for supercop
git clone git://git.finwo.net/app/supercop
Log | Files | Refs | README | LICENSE

armor.h (1067B)


      1 // Shared ascii-armor block locating for the asc format.
      2 //
      3 // A block looks like:
      4 //
      5 //   -----BEGIN <label>-----
      6 //   <base64 payload, 64-col wrapped>
      7 //   -----END <label>-----
      8 //
      9 // All scanning is bounded by the buffer length, never assuming
     10 // NUL-termination.
     11 
     12 #ifndef __SUPERCOP_FMT_ASC_ARMOR_H__
     13 #define __SUPERCOP_FMT_ASC_ARMOR_H__
     14 
     15 #include <stddef.h>
     16 
     17 #ifdef __cplusplus
     18 extern "C" {
     19 #endif
     20 
     21 // Namespaced labels: bare "PRIVATE KEY"/"PUBLIC KEY" would invite openssl
     22 // to misparse our raw payload as DER/PKCS#8.
     23 #define ASC_LABEL_PRIVATE "SUPERCOP PRIVATE KEY"
     24 #define ASC_LABEL_PUBLIC  "SUPERCOP PUBLIC KEY"
     25 
     26 // Locate the first block with the given label. On success sets
     27 // *payload/*payloadlen to the bytes between the markers and returns 1,
     28 // otherwise returns 0. payload/payloadlen may be NULL to just test presence.
     29 int asc_find_block(const unsigned char *buf, size_t len, const char *label,
     30                    const unsigned char **payload, size_t *payloadlen);
     31 
     32 #ifdef __cplusplus
     33 } // extern "C"
     34 #endif
     35 
     36 #endif // __SUPERCOP_FMT_ASC_ARMOR_H__