Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 188691
b: refs/heads/master
c: 8b6e4f2
h: refs/heads/master
i:
  188689: b0a30b9
  188687: 26bdcad
v: v3
  • Loading branch information
Sage Weil committed Feb 10, 2010
1 parent 69a72d0 commit 7e22f60
Show file tree
Hide file tree
Showing 6 changed files with 558 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c7e337d6490d6f2f5e66ddf1b04d00b0dbd10108
refs/heads/master: 8b6e4f2d8b21c25225b1ce8d53a2e03b92cc8522
1 change: 1 addition & 0 deletions trunk/fs/ceph/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ config CEPH_FS
tristate "Ceph distributed file system (EXPERIMENTAL)"
depends on INET && EXPERIMENTAL
select LIBCRC32C
select CONFIG_CRYPTO_AES
help
Choose Y or M here to include support for mounting the
experimental Ceph distributed file system. Ceph is an extremely
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/ceph/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ceph-objs := super.o inode.o dir.o file.o addr.o ioctl.o \
osd_client.o osdmap.o crush/crush.o crush/mapper.o crush/hash.o \
debugfs.o \
auth.o auth_none.o \
crypto.o armor.o \
ceph_fs.o ceph_strings.o ceph_hash.o ceph_frag.o

else
Expand Down
99 changes: 99 additions & 0 deletions trunk/fs/ceph/armor.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

#include <linux/errno.h>

/*
* base64 encode/decode.
*/

const char *pem_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

static int encode_bits(int c)
{
return pem_key[c];
}

static int decode_bits(char c)
{
if (c >= 'A' && c <= 'Z')
return c - 'A';
if (c >= 'a' && c <= 'z')
return c - 'a' + 26;
if (c >= '0' && c <= '9')
return c - '0' + 52;
if (c == '+')
return 62;
if (c == '/')
return 63;
if (c == '=')
return 0; /* just non-negative, please */
return -EINVAL;
}

int ceph_armor(char *dst, const char *src, const char *end)
{
int olen = 0;
int line = 0;

while (src < end) {
unsigned char a, b, c;

a = *src++;
*dst++ = encode_bits(a >> 2);
if (src < end) {
b = *src++;
*dst++ = encode_bits(((a & 3) << 4) | (b >> 4));
if (src < end) {
c = *src++;
*dst++ = encode_bits(((b & 15) << 2) |
(c >> 6));
*dst++ = encode_bits(c & 63);
} else {
*dst++ = encode_bits((b & 15) << 2);
*dst++ = '=';
}
} else {
*dst++ = encode_bits(((a & 3) << 4));
*dst++ = '=';
*dst++ = '=';
}
olen += 4;
line += 4;
if (line == 64) {
line = 0;
*(dst++) = '\n';
olen++;
}
}
return olen;
}

int ceph_unarmor(char *dst, const char *src, const char *end)
{
int olen = 0;

while (src < end) {
int a, b, c, d;

if (src < end && src[0] == '\n')
src++;
if (src + 4 > end)
return -EINVAL;
a = decode_bits(src[0]);
b = decode_bits(src[1]);
c = decode_bits(src[2]);
d = decode_bits(src[3]);
if (a < 0 || b < 0 || c < 0 || d < 0)
return -EINVAL;

*dst++ = (a << 2) | (b >> 4);
if (src[2] == '=')
return olen + 1;
*dst++ = ((b & 15) << 4) | (c >> 2);
if (src[3] == '=')
return olen + 2;
*dst++ = ((c & 3) << 6) | d;
olen += 3;
src += 4;
}
return olen;
}
Loading

0 comments on commit 7e22f60

Please sign in to comment.