[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha4-34-gfa2ecfe

Andrew Tridgell tridge at samba.org
Wed Jun 4 16:43:24 GMT 2008


The branch, v4-0-test has been updated
       via  fa2ecfea7a1acc388a86e8fba5b42df7925c9045 (commit)
       via  d206517f90ac02e829193c5a17e5df25059cf18d (commit)
       via  9d74201e462f2f95ed5bd91200681db3bd2a9277 (commit)
       via  436cb17b869e2d6cc57936ccc5e81680fb992341 (commit)
       via  b8f2e6321dd06508f9cc48e8d76d20232cb7d60e (commit)
       via  63f315572969e7fc52bdc7c0b38eaaee736d5e2a (commit)
       via  85d1873ee92fcc7df3addc42ddb8189144901f8b (commit)
       via  12ecd7f4b8934e3e11e8b6019b92b82a53e55b96 (commit)
       via  7a1877db15e6a57f0f057dcf5da6609b9bdeef51 (commit)
       via  9483b7c137b61d3029a1e1e7d8d8d0723b541129 (commit)
       via  a2854fd6eaf097b5a9a562e0b8f1a599485fec42 (commit)
       via  f84620324a8cebcd2fd19388d910928ca1ad1334 (commit)
       via  7a8ee50105265a4da1f2b89144094f2269c6b119 (commit)
       via  ed8f16379d01d3dffd2645e2b275aa27507dfec9 (commit)
       via  70569a78cf3443ce5c0b0a28dcd17a3031d8aa55 (commit)
      from  feca16dd6d03730b4a67adf5d912ba2d5e1a3025 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit fa2ecfea7a1acc388a86e8fba5b42df7925c9045
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Jun 4 09:42:55 2008 -0700

    copied the Heimdal sha256 functions into lib/crypto to avoid a link
    error
    
    Hopefully we can remove this again later

commit d206517f90ac02e829193c5a17e5df25059cf18d
Merge: 9d74201e462f2f95ed5bd91200681db3bd2a9277 feca16dd6d03730b4a67adf5d912ba2d5e1a3025
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Jun 4 09:25:16 2008 -0700

    Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test

commit 9d74201e462f2f95ed5bd91200681db3bd2a9277
Merge: 436cb17b869e2d6cc57936ccc5e81680fb992341 f65e43e9456e8e951d172779cba53ab417114b20
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jun 3 15:11:42 2008 -0700

    Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test

commit 436cb17b869e2d6cc57936ccc5e81680fb992341
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jun 3 14:29:27 2008 +1000

    SMB2 signing now works. The spec was wrong (and will be fixed in the
    next version)

commit b8f2e6321dd06508f9cc48e8d76d20232cb7d60e
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jun 3 09:36:46 2008 +1000

    setpassword should be executable

commit 63f315572969e7fc52bdc7c0b38eaaee736d5e2a
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jun 3 09:36:02 2008 +1000

    it is not valid to set a UNLOCK flag on a lock request

commit 85d1873ee92fcc7df3addc42ddb8189144901f8b
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 2 11:05:06 2008 +1000

    more updates for new info levels

commit 12ecd7f4b8934e3e11e8b6019b92b82a53e55b96
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 2 11:04:46 2008 +1000

    remove a pstring

commit 7a1877db15e6a57f0f057dcf5da6609b9bdeef51
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 2 11:04:36 2008 +1000

    remove unused macros

commit 9483b7c137b61d3029a1e1e7d8d8d0723b541129
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 2 11:04:13 2008 +1000

    smbpid is 32 bit, and update SMB2 locking per MS-SMB2
    
    The UNLOCK bit is only used from the first lock structure

commit a2854fd6eaf097b5a9a562e0b8f1a599485fec42
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 2 11:03:19 2008 +1000

    smbpid needs to be 32 bit now to cope with SMB2

commit f84620324a8cebcd2fd19388d910928ca1ad1334
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 2 11:02:57 2008 +1000

    updated some info levels based on WSPP docs

commit 7a8ee50105265a4da1f2b89144094f2269c6b119
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 2 11:02:37 2008 +1000

    fixed a warning

commit ed8f16379d01d3dffd2645e2b275aa27507dfec9
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sat May 31 13:39:51 2008 +1000

    check for requested buffer size in getinfo call

commit 70569a78cf3443ce5c0b0a28dcd17a3031d8aa55
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sat May 31 13:39:34 2008 +1000

    more useful output in scan

-----------------------------------------------------------------------

Summary of changes:
 source/lib/crypto/config.mk        |    3 +-
 source/lib/crypto/crypto.h         |    2 +
 source/lib/crypto/hmacsha256.c     |   91 ++++++++++++++
 source/lib/crypto/hmacsha256.h     |   38 ++++++
 source/lib/crypto/sha256.c         |  234 ++++++++++++++++++++++++++++++++++++
 source/lib/crypto/sha256.h         |   91 ++++++++++++++
 source/lib/torture/torture.h       |    2 +-
 source/libcli/raw/interfaces.h     |   17 ++-
 source/libcli/raw/rawsetfileinfo.c |   29 ++++-
 source/libcli/raw/trans2.h         |   27 +++--
 source/libcli/smb2/signing.c       |   21 ++--
 source/ntvfs/common/brlock.c       |    2 +-
 source/ntvfs/common/brlock_tdb.c   |    8 +-
 source/ntvfs/ntvfs.h               |    2 +-
 source/ntvfs/ntvfs_generic.c       |   45 ++++----
 source/ntvfs/posix/pvfs_lock.c     |    2 +-
 source/ntvfs/posix/pvfs_oplock.c   |    2 +-
 source/smb_server/smb/trans2.c     |   15 ++-
 source/smb_server/smb2/fileinfo.c  |    5 +
 source/smb_server/smb2/tcon.c      |    2 +-
 source/torture/basic/delaywrite.c  |   12 --
 source/torture/gentest.c           |   15 ++-
 source/torture/nbench/nbench.c     |    3 +-
 source/torture/smb2/getinfo.c      |   35 ++++++
 source/torture/smb2/scan.c         |   17 +--
 25 files changed, 617 insertions(+), 103 deletions(-)
 create mode 100644 source/lib/crypto/hmacsha256.c
 create mode 100644 source/lib/crypto/hmacsha256.h
 create mode 100644 source/lib/crypto/sha256.c
 create mode 100644 source/lib/crypto/sha256.h
 mode change 100644 => 100755 source/setup/setpassword


Changeset truncated at 500 lines:

diff --git a/source/lib/crypto/config.mk b/source/lib/crypto/config.mk
index f771a0e..ee111bd 100644
--- a/source/lib/crypto/config.mk
+++ b/source/lib/crypto/config.mk
@@ -6,8 +6,7 @@
 
 LIBCRYPTO_OBJ_FILES = $(addprefix $(libcryptosrcdir)/, \
 					 crc32.o md5.o hmacmd5.o md4.o \
-					 arcfour.o)
-
+					 arcfour.o sha256.o hmacsha256.o)
 
 [MODULE::TORTURE_LIBCRYPTO]
 SUBSYSTEM = smbtorture
diff --git a/source/lib/crypto/crypto.h b/source/lib/crypto/crypto.h
index 513ae78..fc283f7 100644
--- a/source/lib/crypto/crypto.h
+++ b/source/lib/crypto/crypto.h
@@ -21,6 +21,8 @@
 #include "lib/crypto/md4.h"
 #include "lib/crypto/md5.h"
 #include "lib/crypto/hmacmd5.h"
+#include "lib/crypto/sha256.h"
+#include "lib/crypto/hmacsha256.h"
 
 struct arcfour_state {
 	uint8_t sbox[256];
diff --git a/source/lib/crypto/hmacsha256.c b/source/lib/crypto/hmacsha256.c
new file mode 100644
index 0000000..6b0af9e
--- /dev/null
+++ b/source/lib/crypto/hmacsha256.c
@@ -0,0 +1,91 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   Interface header:    HMAC SHA-256 code
+
+   Copyright (C) Andrew Tridgell 2008
+
+   based in hmacsha1.c which is:
+     Copyright (C) Stefan Metzmacher
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ taken direct from rfc2202 implementation and modified for suitable use
+ */
+
+#include "includes.h"
+#include "lib/crypto/crypto.h"
+
+/***********************************************************************
+ the rfc 2104/2202 version of hmac_sha256 initialisation.
+***********************************************************************/
+_PUBLIC_ void hmac_sha256_init(const uint8_t *key, size_t key_len, struct HMACSHA256Context *ctx)
+{
+        int i;
+	uint8_t tk[SHA256_DIGEST_LENGTH];
+
+        /* if key is longer than 64 bytes reset it to key=HASH(key) */
+        if (key_len > 64)
+	{
+                SHA256_CTX tctx;
+
+                SHA256_Init(&tctx);
+                SHA256_Update(&tctx, key, key_len);
+                SHA256_Final(tk, &tctx);
+
+                key = tk;
+                key_len = SHA256_DIGEST_LENGTH;
+        }
+
+        /* start out by storing key in pads */
+        ZERO_STRUCT(ctx->k_ipad);
+        ZERO_STRUCT(ctx->k_opad);
+        memcpy( ctx->k_ipad, key, key_len);
+        memcpy( ctx->k_opad, key, key_len);
+
+        /* XOR key with ipad and opad values */
+        for (i=0; i<64; i++)
+	{
+                ctx->k_ipad[i] ^= 0x36;
+                ctx->k_opad[i] ^= 0x5c;
+        }
+
+        SHA256_Init(&ctx->ctx);
+        SHA256_Update(&ctx->ctx, ctx->k_ipad, 64);  
+}
+
+/***********************************************************************
+ update hmac_sha256 "inner" buffer
+***********************************************************************/
+_PUBLIC_ void hmac_sha256_update(const uint8_t *data, size_t data_len, struct HMACSHA256Context *ctx)
+{
+        SHA256_Update(&ctx->ctx, data, data_len); /* then text of datagram */
+}
+
+/***********************************************************************
+ finish off hmac_sha256 "inner" buffer and generate outer one.
+***********************************************************************/
+_PUBLIC_ void hmac_sha256_final(uint8_t digest[SHA256_DIGEST_LENGTH], struct HMACSHA256Context *ctx)
+{
+        SHA256_CTX ctx_o;
+
+        SHA256_Final(digest, &ctx->ctx);
+
+        SHA256_Init(&ctx_o);
+        SHA256_Update(&ctx_o, ctx->k_opad, 64);
+        SHA256_Update(&ctx_o, digest, SHA256_DIGEST_LENGTH);
+        SHA256_Final(digest, &ctx_o);
+}
diff --git a/source/lib/crypto/hmacsha256.h b/source/lib/crypto/hmacsha256.h
new file mode 100644
index 0000000..8960c63
--- /dev/null
+++ b/source/lib/crypto/hmacsha256.h
@@ -0,0 +1,38 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   Interface header:    HMAC SHA256 code
+
+   Copyright (C) Andrew Tridgell 2008
+
+   based on hmacsha1.h which is:
+
+    Copyright (C) Stefan Metzmacher 2006
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _HMAC_SHA256_H
+
+struct HMACSHA256Context {
+        SHA256_CTX ctx;
+        uint8_t k_ipad[65];    
+        uint8_t k_opad[65];
+};
+
+void hmac_sha256_init(const uint8_t *key, size_t key_len, struct HMACSHA256Context *ctx);
+void hmac_sha256_update(const uint8_t *data, size_t data_len, struct HMACSHA256Context *ctx);
+void hmac_sha256_final(uint8_t digest[20], struct HMACSHA256Context *ctx);
+
+#endif /* _HMAC_SHA256_H */
diff --git a/source/lib/crypto/sha256.c b/source/lib/crypto/sha256.c
new file mode 100644
index 0000000..70fe7a3
--- /dev/null
+++ b/source/lib/crypto/sha256.c
@@ -0,0 +1,234 @@
+/*
+  based on heildal lib/hcrypto/sha256.c. Copied to lib/crypto to avoid a link
+  problem. Hopefully will be removed once we solve this link problem
+
+   (tridge)
+ */
+
+/*
+ * Copyright (c) 2006 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "includes.h"
+#include "heimdal/lib/hcrypto/hash.h"
+#include "sha256.h"
+
+#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
+#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+
+#define ROTR(x,n)   (((x)>>(n)) | ((x) << (32 - (n))))
+
+#define Sigma0(x)	(ROTR(x,2)  ^ ROTR(x,13) ^ ROTR(x,22))
+#define Sigma1(x)	(ROTR(x,6)  ^ ROTR(x,11) ^ ROTR(x,25))
+#define sigma0(x)	(ROTR(x,7)  ^ ROTR(x,18) ^ ((x)>>3))
+#define sigma1(x)	(ROTR(x,17) ^ ROTR(x,19) ^ ((x)>>10))
+
+#define A m->counter[0]
+#define B m->counter[1]
+#define C m->counter[2]
+#define D m->counter[3]
+#define E m->counter[4]
+#define F m->counter[5]
+#define G m->counter[6]
+#define H m->counter[7]
+
+static const uint32_t constant_256[64] = {
+    0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+    0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+    0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+    0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+    0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+    0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+    0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+    0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+    0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+    0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+    0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+    0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+    0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+    0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+    0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+    0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+};
+
+void
+SHA256_Init (SHA256_CTX *m)
+{
+    m->sz[0] = 0;
+    m->sz[1] = 0;
+    A = 0x6a09e667;
+    B = 0xbb67ae85;
+    C = 0x3c6ef372;
+    D = 0xa54ff53a;
+    E = 0x510e527f;
+    F = 0x9b05688c;
+    G = 0x1f83d9ab;
+    H = 0x5be0cd19;
+}
+
+static void
+calc (SHA256_CTX *m, uint32_t *in)
+{
+    uint32_t AA, BB, CC, DD, EE, FF, GG, HH;
+    uint32_t data[64];
+    int i;
+
+    AA = A;
+    BB = B;
+    CC = C;
+    DD = D;
+    EE = E;
+    FF = F;
+    GG = G;
+    HH = H;
+
+    for (i = 0; i < 16; ++i)
+	data[i] = in[i];
+    for (i = 16; i < 64; ++i)
+	data[i] = sigma1(data[i-2]) + data[i-7] + 
+	    sigma0(data[i-15]) + data[i - 16];
+
+    for (i = 0; i < 64; i++) {
+	uint32_t T1, T2;
+
+	T1 = HH + Sigma1(EE) + Ch(EE, FF, GG) + constant_256[i] + data[i];
+	T2 = Sigma0(AA) + Maj(AA,BB,CC);
+			     
+	HH = GG;
+	GG = FF;
+	FF = EE;
+	EE = DD + T1;
+	DD = CC;
+	CC = BB;
+	BB = AA;
+	AA = T1 + T2;
+    }
+
+    A += AA;
+    B += BB;
+    C += CC;
+    D += DD;
+    E += EE;
+    F += FF;
+    G += GG;
+    H += HH;
+}
+
+/*
+ * From `Performance analysis of MD5' by Joseph D. Touch <touch at isi.edu>
+ */
+
+#if !defined(WORDS_BIGENDIAN) || defined(_CRAY)
+static inline uint32_t
+swap_uint32_t (uint32_t t)
+{
+    uint32_t temp1, temp2;
+
+    temp1   = cshift(t, 16);
+    temp2   = temp1 >> 8;
+    temp1  &= 0x00ff00ff;
+    temp2  &= 0x00ff00ff;
+    temp1 <<= 8;
+    return temp1 | temp2;
+}
+#endif
+
+struct x32{
+    unsigned int a:32;
+    unsigned int b:32;
+};
+
+void
+SHA256_Update (SHA256_CTX *m, const void *v, size_t len)
+{
+    const unsigned char *p = v;
+    size_t old_sz = m->sz[0];
+    size_t offset;
+
+    m->sz[0] += len * 8;
+    if (m->sz[0] < old_sz)
+	++m->sz[1];
+    offset = (old_sz / 8) % 64;
+    while(len > 0){
+	size_t l = min(len, 64 - offset);
+	memcpy(m->save + offset, p, l);
+	offset += l;
+	p += l;
+	len -= l;
+	if(offset == 64){
+#if !defined(WORDS_BIGENDIAN) || defined(_CRAY)
+	    int i;
+	    uint32_t current[16];
+	    struct x32 *u = (struct x32*)m->save;
+	    for(i = 0; i < 8; i++){
+		current[2*i+0] = swap_uint32_t(u[i].a);
+		current[2*i+1] = swap_uint32_t(u[i].b);
+	    }
+	    calc(m, current);
+#else
+	    calc(m, (uint32_t*)m->save);
+#endif
+	    offset = 0;
+	}
+    }
+}
+
+void
+SHA256_Final (void *res, SHA256_CTX *m)
+{
+    unsigned char zeros[72];
+    unsigned offset = (m->sz[0] / 8) % 64;
+    unsigned int dstart = (120 - offset - 1) % 64 + 1;
+
+    *zeros = 0x80;
+    memset (zeros + 1, 0, sizeof(zeros) - 1);
+    zeros[dstart+7] = (m->sz[0] >> 0) & 0xff;
+    zeros[dstart+6] = (m->sz[0] >> 8) & 0xff;
+    zeros[dstart+5] = (m->sz[0] >> 16) & 0xff;
+    zeros[dstart+4] = (m->sz[0] >> 24) & 0xff;
+    zeros[dstart+3] = (m->sz[1] >> 0) & 0xff;
+    zeros[dstart+2] = (m->sz[1] >> 8) & 0xff;
+    zeros[dstart+1] = (m->sz[1] >> 16) & 0xff;
+    zeros[dstart+0] = (m->sz[1] >> 24) & 0xff;
+    SHA256_Update (m, zeros, dstart + 8);
+    {
+	int i;
+	unsigned char *r = (unsigned char*)res;
+
+	for (i = 0; i < 8; ++i) {
+	    r[4*i+3] = m->counter[i] & 0xFF;
+	    r[4*i+2] = (m->counter[i] >> 8) & 0xFF;
+	    r[4*i+1] = (m->counter[i] >> 16) & 0xFF;
+	    r[4*i]   = (m->counter[i] >> 24) & 0xFF;
+	}
+    }
+}
diff --git a/source/lib/crypto/sha256.h b/source/lib/crypto/sha256.h
new file mode 100644
index 0000000..4a5f2cb
--- /dev/null
+++ b/source/lib/crypto/sha256.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* $Id: sha.h 17450 2006-05-05 11:11:43Z lha $ */
+
+#ifndef HEIM_SHA_H
+/*
+  based on heildal lib/hcrypto/sha.h. Copied to lib/crypto to avoid a link
+  problem. Hopefully will be removed once we solve this link problem
+
+   (tridge)
+ */
+#define HEIM_SHA_H 1
+
+#if 0
+/* symbol renaming */
+#define SHA1_Init hc_SHA1_Init
+#define SHA1_Update hc_SHA1_Update
+#define SHA1_Final hc_SHA1_Final
+#define SHA256_Init hc_SHA256_Init
+#define SHA256_Update hc_SHA256_Update
+#define SHA256_Final hc_SHA256_Final
+#endif
+
+/*
+ * SHA-1
+ */
+
+#define SHA_DIGEST_LENGTH 20
+
+struct sha {
+  unsigned int sz[2];
+  uint32_t counter[5];
+  unsigned char save[64];
+};
+
+typedef struct sha SHA_CTX;
+
+void SHA1_Init (struct sha *m);
+void SHA1_Update (struct sha *m, const void *v, size_t len);
+void SHA1_Final (void *res, struct sha *m);
+
+/*
+ * SHA-2 256
+ */
+
+#define SHA256_DIGEST_LENGTH 32
+
+struct hc_sha256state {
+  unsigned int sz[2];
+  uint32_t counter[8];
+  unsigned char save[64];
+};
+
+typedef struct hc_sha256state SHA256_CTX;
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list