crypto/modes: make modes.h selfsufficient and rename block_f to block128_t.
authorAndy Polyakov <appro@openssl.org>
Tue, 23 Dec 2008 11:18:45 +0000 (11:18 +0000)
committerAndy Polyakov <appro@openssl.org>
Tue, 23 Dec 2008 11:18:45 +0000 (11:18 +0000)
crypto/modes/cbc128.c
crypto/modes/cfb128.c
crypto/modes/ctr128.c
crypto/modes/modes.h
crypto/modes/ofb128.c

index af844b6..8f8bd56 100644 (file)
@@ -48,7 +48,7 @@
  *
  */
 
-#include <stddef.h>
+#include "modes.h"
 #include <string.h>
 
 #ifndef MODES_DEBUG
@@ -58,8 +58,6 @@
 #endif
 #include <assert.h>
 
-#include "modes.h"
-
 #define STRICT_ALIGNMENT 1
 #if defined(__i386) || defined(__i386__) || \
     defined(__x86_64) || defined(__x86_64__) || \
@@ -71,7 +69,7 @@
 
 void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
-                       unsigned char ivec[16], block_f block)
+                       unsigned char ivec[16], block128_f block)
 {
        size_t n;
        const unsigned char *iv = ivec;
@@ -120,7 +118,7 @@ void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
 
 void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
-                       unsigned char ivec[16], block_f block)
+                       unsigned char ivec[16], block128_f block)
 {
        size_t n;
        union { size_t align; unsigned char c[16]; } tmp;
index 0512c3f..9ba4984 100644 (file)
@@ -48,7 +48,7 @@
  *
  */
 
-#include <stddef.h>
+#include "modes.h"
 #include <string.h>
 
 #ifndef MODES_DEBUG
@@ -58,8 +58,6 @@
 #endif
 #include <assert.h>
 
-#include "modes.h"
-
 #define STRICT_ALIGNMENT
 #if defined(__i386) || defined(__i386__) || \
     defined(__x86_64) || defined(__x86_64__) || \
@@ -75,7 +73,7 @@
 void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
                        unsigned char ivec[16], int *num,
-                       int enc, block_f block)
+                       int enc, block128_f block)
 {
     unsigned int n;
     size_t l = 0;
@@ -184,7 +182,7 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
 static void cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
                            int nbits,const void *key,
                            unsigned char ivec[16],int enc,
-                           block_f block)
+                           block128_f block)
 {
     int n,rem,num;
     unsigned char ovec[16*2 + 1];  /* +1 because we dererefence (but don't use) one byte off the end */
@@ -218,7 +216,7 @@ static void cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
 void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
                        size_t bits, const void *key,
                        unsigned char ivec[16], int *num,
-                       int enc, block_f block)
+                       int enc, block128_f block)
 {
     size_t n;
     unsigned char c[1],d[1];
@@ -238,7 +236,7 @@ void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
 void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
                        size_t length, const void *key,
                        unsigned char ivec[16], int *num,
-                       int enc, block_f block)
+                       int enc, block128_f block)
 {
     size_t n;
 
index db79c76..bd84f41 100644 (file)
@@ -48,7 +48,7 @@
  *
  */
 
-#include <stddef.h>
+#include "modes.h"
 #include <string.h>
 
 #ifndef MODES_DEBUG
@@ -58,8 +58,6 @@
 #endif
 #include <assert.h>
 
-#include "modes.h"
-
 typedef unsigned int u32;
 typedef unsigned char u8;
 
@@ -128,7 +126,7 @@ static void ctr128_inc_aligned(unsigned char *counter) {
 void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
                        unsigned char ivec[16], unsigned char ecount_buf[16],
-                       unsigned int *num, block_f block)
+                       unsigned int *num, block128_f block)
 {
        unsigned int n;
        size_t l=0;
index 87e0ec6..6315a60 100644 (file)
@@ -1,34 +1,42 @@
-typedef void (*block_f)(const unsigned char in[16],
+/* ====================================================================
+ * Copyright (c) 2008 The OpenSSL Project. All rights reserved.
+ *
+ * Rights for redistribution and usage in source and binary
+ * forms are granted according to the OpenSSL license.
+ */
+
+#include <stddef.h>
+
+typedef void (*block128_f)(const unsigned char in[16],
                        unsigned char out[16],
                        const void *key);
 
 void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
-                       unsigned char ivec[16], block_f block);
+                       unsigned char ivec[16], block128_f block);
 void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
-                       unsigned char ivec[16], block_f block);
+                       unsigned char ivec[16], block128_f block);
 
 void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
                        unsigned char ivec[16], unsigned char ecount_buf[16],
-                       unsigned int *num, block_f block);
+                       unsigned int *num, block128_f block);
 
 void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
                        unsigned char ivec[16], int *num,
-                       block_f block);
+                       block128_f block);
 
 void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
                        unsigned char ivec[16], int *num,
-                       int enc, block_f block);
+                       int enc, block128_f block);
 void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
                        size_t length, const void *key,
                        unsigned char ivec[16], int *num,
-                       int enc, block_f block);
+                       int enc, block128_f block);
 void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
                        size_t bits, const void *key,
                        unsigned char ivec[16], int *num,
-                       int enc, block_f block);
-
+                       int enc, block128_f block);
index ae264c8..09b3430 100644 (file)
@@ -48,7 +48,7 @@
  *
  */
 
-#include <stddef.h>
+#include "modes.h"
 #include <string.h>
 
 #ifndef MODES_DEBUG
@@ -58,8 +58,6 @@
 #endif
 #include <assert.h>
 
-#include "modes.h"
-
 #define STRICT_ALIGNMENT
 #if defined(__i386) || defined(__i386__) || \
     defined(__x86_64) || defined(__x86_64__) || \
@@ -75,7 +73,7 @@
 void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
                        unsigned char ivec[16], int *num,
-                       block_f block)
+                       block128_f block)
 {
        unsigned int n;
        size_t l=0;