linux/net/ceph/armor.c
<<
>>
Prefs
   1
   2#include <linux/errno.h>
   3
   4int ceph_armor(char *dst, const char *src, const char *end);
   5int ceph_unarmor(char *dst, const char *src, const char *end);
   6
   7/*
   8 * base64 encode/decode.
   9 */
  10
  11static const char *pem_key =
  12        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  13
  14static int encode_bits(int c)
  15{
  16        return pem_key[c];
  17}
  18
  19static int decode_bits(char c)
  20{
  21        if (c >= 'A' && c <= 'Z')
  22                return c - 'A';
  23        if (c >= 'a' && c <= 'z')
  24                return c - 'a' + 26;
  25        if (c >= '0' && c <= '9
  
  
  
   + 26;
  25        if (c <= '9