summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/comp/c_rle.c
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>1999-09-29 05:53:22 +0000
committerbeck <beck@openbsd.org>1999-09-29 05:53:22 +0000
commit7695d5a3080c378e2142f67b0a7b82b43cf3e128 (patch)
tree3756a4e9200b1baa4df44aac2dfadec2014445f6 /lib/libcrypto/comp/c_rle.c
parentbuild openssl instead of ssleay (diff)
downloadwireguard-openbsd-7695d5a3080c378e2142f67b0a7b82b43cf3e128.tar.xz
wireguard-openbsd-7695d5a3080c378e2142f67b0a7b82b43cf3e128.zip
new files for OpenSSL 0.9.4
Diffstat (limited to 'lib/libcrypto/comp/c_rle.c')
-rw-r--r--lib/libcrypto/comp/c_rle.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/libcrypto/comp/c_rle.c b/lib/libcrypto/comp/c_rle.c
new file mode 100644
index 00000000000..1a819e3737d
--- /dev/null
+++ b/lib/libcrypto/comp/c_rle.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <openssl/objects.h>
+#include <openssl/comp.h>
+
+static int rle_compress_block(COMP_CTX *ctx, unsigned char *out,
+ unsigned int olen, unsigned char *in, unsigned int ilen);
+static int rle_expand_block(COMP_CTX *ctx, unsigned char *out,
+ unsigned int olen, unsigned char *in, unsigned int ilen);
+
+static COMP_METHOD rle_method={
+ NID_rle_compression,
+ LN_rle_compression,
+ NULL,
+ NULL,
+ rle_compress_block,
+ rle_expand_block,
+ NULL,
+ };
+
+COMP_METHOD *COMP_rle(void)
+ {
+ return(&rle_method);
+ }
+
+static int rle_compress_block(COMP_CTX *ctx, unsigned char *out,
+ unsigned int olen, unsigned char *in, unsigned int ilen)
+ {
+ /* int i; */
+
+ if (olen < (ilen+1))
+ {
+ /* ZZZZZZZZZZZZZZZZZZZZZZ */
+ return(-1);
+ }
+
+ *(out++)=0;
+ memcpy(out,in,ilen);
+ return(ilen+1);
+ }
+
+static int rle_expand_block(COMP_CTX *ctx, unsigned char *out,
+ unsigned int olen, unsigned char *in, unsigned int ilen)
+ {
+ int i;
+
+ if (olen < (ilen-1))
+ {
+ /* ZZZZZZZZZZZZZZZZZZZZZZ */
+ return(-1);
+ }
+
+ i= *(in++);
+ if (i == 0)
+ {
+ memcpy(out,in,ilen-1);
+ }
+ return(ilen-1);
+ }
+