mirror of
https://github.com/ceph/ceph
synced 2024-12-22 03:22:00 +00:00
d447a80815
RADOS classes can now be statically compiled and added to the embedded cephd library. The RADOS ClassHandler now has an option to skip calling dlclose just like PluginRegistry. All RADOS classes where changed to use a CLS_INIT macro that will either use __cls_init or classname_cls_init. this enables the static compiling of all RADOS classes in a single library. Also global method definitions where moved to inside cls_init. Also added a few aconfig defines including WITH_EMBEDDED, WITH_CEPHFS, WITH_RBD, and WITH_KVS. Note that WITH_RBD was not defined before and the ceph-dencoder was broken when it was turned on. Signed-off-by: Bassam Tabbara <bassam.tabbara@quantum.com>
77 lines
1.5 KiB
C++
77 lines
1.5 KiB
C++
#include <iostream>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
|
|
#include <openssl/md5.h>
|
|
#include <openssl/sha.h>
|
|
|
|
#include "include/types.h"
|
|
#include "objclass/objclass.h"
|
|
|
|
|
|
CLS_VER(1,0)
|
|
CLS_NAME(crypto)
|
|
|
|
int md5_method(cls_method_context_t ctx, char *indata, int datalen,
|
|
char **outdata, int *outdatalen)
|
|
{
|
|
MD5_CTX c;
|
|
unsigned char *md;
|
|
|
|
cls_log("md5 method");
|
|
cls_log("indata=%.*s data_len=%d", datalen, indata, datalen);
|
|
|
|
md = (unsigned char *)cls_alloc(MD5_DIGEST_LENGTH);
|
|
if (!md)
|
|
return -ENOMEM;
|
|
|
|
MD5_Init(&c);
|
|
MD5_Update(&c, indata, (unsigned long)datalen);
|
|
MD5_Final(md,&c);
|
|
|
|
*outdata = (char *)md;
|
|
*outdatalen = MD5_DIGEST_LENGTH;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int sha1_method(cls_method_context_t ctx, char *indata, int datalen,
|
|
char **outdata, int *outdatalen)
|
|
{
|
|
SHA_CTX c;
|
|
unsigned char *md;
|
|
|
|
cls_log("sha1 method");
|
|
cls_log("indata=%.*s data_len=%d", datalen, indata, datalen);
|
|
|
|
md = (unsigned char *)cls_alloc(SHA_DIGEST_LENGTH);
|
|
if (!md)
|
|
return -ENOMEM;
|
|
|
|
SHA1_Init(&c);
|
|
SHA1_Update(&c, indata, (unsigned long)datalen);
|
|
SHA1_Final(md,&c);
|
|
|
|
*outdata = (char *)md;
|
|
*outdatalen = SHA_DIGEST_LENGTH;
|
|
|
|
return 0;
|
|
}
|
|
|
|
CLS_INIT(crypto)
|
|
{
|
|
cls_log("Loaded crypto class!");
|
|
|
|
cls_handle_t h_class;
|
|
cls_method_handle_t h_md5;
|
|
cls_method_handle_t h_sha1;
|
|
|
|
cls_register("crypto", &h_class);
|
|
cls_register_method(h_class, "md5", CLS_METHOD_RD, md5_method, &h_md5);
|
|
cls_register_method(h_class, "sha1", CLS_METHOD_RD, sha1_method, &h_sha1);
|
|
|
|
return;
|
|
}
|
|
|