[SCM] Samba Shared Repository - branch v4-3-test updated

Stefan Metzmacher metze at samba.org
Mon Aug 31 11:24:03 UTC 2015


The branch, v4-3-test has been updated
       via  8370cb4 winbind: Remove "have_idmap_config" from winbindd_domain
       via  4e987b3 winbind: Do not look for the domain in wb_gid2sid
       via  9021612 winbind: Do not look for the domain in wb_uid2sid
       via  79a1174 idmap: Remove dom_name from wbint_Gid2Sid
       via  617687d idmap: Remove dom_name from wbint_Uid2Sid
       via  7f4b57e idmap: Remove "domname" from idmap_gid_to_sid
       via  92976d0 idmap: Remove "domname" from idmap_uid_to_sid
       via  64450da idmap: Remove "domname" from idmap_backends_unixid_to_sid
       via  9de5e9b idmap: Use a range search in idmap_backends_unixid_to_sid
       via  4fed476 idmap: Initialize all idmap domains at startup
       via  56ac018 idmap: Move idmap_init() under the static vars
       via  ef97c16 loadparm3: Add lp_wi_scan_global_parametrics()
       via  f484b24 lib/crypto: make it possible to use only parts of aes.[ch]
       via  922732a lib/crypto: sync AES_cfb8_encrypt() from heimdal
       via  8863034 lib/crypto: make use of aes_test.h in aes_gcm_128_test.c
       via  d7e5e1e lib/crypto: optimize aes_gcm_128
       via  e5b015c lib/crypto: optimize aes_ccm_128
       via  ec84abe lib/crypto: optimize aes_cmac_128
       via  3a63317 lib/crypto: add optimized helper functions aes_block_{xor,lshift,rshift}()
       via  da29dc5 lib/crypto: add aes_ccm_128 tests
       via  a4bc721 lib/crypto: verify 0 updates in aes_gcm_128 tests
       via  33c7c5a lib/crypto: run all aes_gcm_128 testcases
       via  862b204 lib/crypto: add aes_cmac_128 chunked tests
       via  c3ecf14 s3:vfs_smb_traffic_analyzer: remove samba_ prefix from AES_* function calls
       via  8fc7a9a vfs: fix build warning in smb traffic analyzer.
       via  ae3c0c8 s3-util: Compare the maximum allowed length of a NetBIOS name
       via  aca49d0 s3-auth: Fix a memory leak in make_server_info_info3()
       via  f5c6c89 s3-auth: Pass nt_username to check_account()
       via  3271b5b s3-auth: Fix 'map to guest = Bad Uid' support
      from  f55942d s4-torture: don't build the lsa forest trust krb5 tests when building with MIT Kerberos.

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-3-test


- Log -----------------------------------------------------------------
commit 8370cb4c012ab813c7f19c54686c82a81a03da64
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 21 11:25:33 2015 +0200

    winbind: Remove "have_idmap_config" from winbindd_domain
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Mon Aug 24 19:19:31 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 617bc3fe611266b8d3d0fd47b839d4ac8ad73f8f)
    
    Autobuild-User(v4-3-test): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(v4-3-test): Mon Aug 31 13:23:48 CEST 2015 on sn-devel-104

commit 4e987b39ab6e5e2d5e87282b1008ac49a392c1ae
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 19 13:48:17 2015 +0200

    winbind: Do not look for the domain in wb_gid2sid
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit b62c7e26b4783cdff11e406e4d75bc2e0fba7933)

commit 9021612c3da01bcd07f9dae5a7f2e5dae80ce59f
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 19 13:48:17 2015 +0200

    winbind: Do not look for the domain in wb_uid2sid
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit 2387d03b8ae9a471694503677667e623dff8ef88)

commit 79a1174e10715c1fb40766a5be39b9f863991057
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 19 13:44:02 2015 +0200

    idmap: Remove dom_name from wbint_Gid2Sid
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit 8856555af43848830b7c1e47765d26ce59dfa62b)

commit 617687d0ad075c370999d54e032dbd7adee6537b
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 19 13:44:02 2015 +0200

    idmap: Remove dom_name from wbint_Uid2Sid
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit d4730474da30c707339e21746c27eed5871cfdfe)

commit 7f4b57ebf910d5fc48964e3328d06eaf374750b4
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 19 13:34:58 2015 +0200

    idmap: Remove "domname" from idmap_gid_to_sid
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit 2f4dad52c77c7d0aaad2a4ccc0cb7dff0d129612)

commit 92976d0c0665b193ec98e72dab3323a6718e5817
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 19 13:34:58 2015 +0200

    idmap: Remove "domname" from idmap_uid_to_sid
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit 0f8c9b8d7f9a3ca288e42d857d253137e048d4bc)

commit 64450da768406a8ab4ad7f3830dd5f36081cbac7
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 18 17:34:29 2015 +0200

    idmap: Remove "domname" from idmap_backends_unixid_to_sid
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit ac4cc243771fc3273872547087679db21c9bb1cb)

commit 9de5e9bc471ed0a37763f9ee0313068ef71a3c58
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 18 17:30:27 2015 +0200

    idmap: Use a range search in idmap_backends_unixid_to_sid
    
    This obsoletes the domain name in the xid2sid calls
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit ad626b9e6b3c200c70b0d840c956f7b6fff20660)

commit 4fed47622629c18db5374524e6338bbc75314afe
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 19 17:00:46 2015 +0200

    idmap: Initialize all idmap domains at startup
    
    So far we have initialized idmap domains on demand indexed by name.
    For sid2xid this works okay, because we could do lookupsids before
    and thus get the name. For xid2sid this is more problematic. We
    have to rely on enumtrustdoms to work completely, and we have to
    look at the list of winbind domains in the parent to get the domain
    name. Relying on domain->have_idmap_config is not particularly nice.
    
    This patch re-works initialization of idmap domains by scanning all
    parametric parameters, scanning for :backend configuration settings.
    This way we get a complete list of :range definitions. This means
    we can rely on the idmap domain array to be complete. This in turn
    means we can live without the domain name to find a domain, we can
    do a range search by uid or gid.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit ef0c91195533d95ba4fb7947ff5f69c20aa677b8)

commit 56ac018db83bdd507bc32e76fd3404e1e4eb392d
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 18 16:58:02 2015 +0200

    idmap: Move idmap_init() under the static vars
    
    Just moving code, idmap_init will need to reference the variables
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit d36de86639b7782e1e959d61917d8f19fdfc902c)

commit ef97c16c6729e3bc516c6719580f964dde1fa298
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 18 13:18:33 2015 +0200

    loadparm3: Add lp_wi_scan_global_parametrics()
    
    This routine takes a regex and goes through all parametric parameters
    in [global], matching the regex. It can easily be extended to also
    look at shares, but right now it will only be used to list all idmap
    config domain names.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11464
    (cherry picked from commit 443dd9bbbc641ede10a2a3708465f61ea3dfbde3)

commit f484b247068f6e120984b7fec6f6f641040f3c04
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 12 12:58:49 2015 +0200

    lib/crypto: make it possible to use only parts of aes.[ch]
    
    This can be used in order to optimize some parts later.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Aug 27 23:23:54 CEST 2015 on sn-devel-104
    
    (cherry picked from commit d9166eb2d7880d0717dbf231b02d50c2a331827e)

commit 922732a00151c4c81cd6ae1a8710bb46f24c6985
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 12 12:58:49 2015 +0200

    lib/crypto: sync AES_cfb8_encrypt() from heimdal
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit aaad9e9618686066ed24fef43cb3872fb9861678)

commit 8863034e91672238ab65016fc2f5d84d34ecd423
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 14 23:45:07 2015 +0200

    lib/crypto: make use of aes_test.h in aes_gcm_128_test.c
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit e9d3379d72f5698d579842d2f1aafa4fd0dde56f)

commit d7e5e1e7593253dc5b53a29c12936b11f0a298d9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 12 00:59:58 2015 +0200

    lib/crypto: optimize aes_gcm_128
    
    - We avoid variables in order to do a lazy cleanup
      in aes_ccm_128_digest() via ZERO_STRUCTP(ctx)
    - We use the optimized aes_block_{xor,rshift}() functions
    - Align AES_BLOCK_SIZE arrays to 8 bytes
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 965f04d5e6c34cc56809ab42abe506ae1a7530ce)

commit e5b015c9bee3ce46ced98137cfb67b90b86ef815
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 12 00:59:58 2015 +0200

    lib/crypto: optimize aes_ccm_128
    
    - We avoid variables in order to do a lazy cleanup
      in aes_ccm_128_digest() via ZERO_STRUCTP(ctx)
    - We use the optimized aes_block_xor() function
    - We reuse A_i instead of rebuilding it everything completely.
    - Align AES_BLOCK_SIZE arrays to 8 bytes
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 7e8333dac3922104849da0fde9528e2c2c36b6c9)

commit ec84abe68a24206632a5b9b03bbb11ce4ac8a662
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 12 00:59:58 2015 +0200

    lib/crypto: optimize aes_cmac_128
    
    - We avoid variables in order to do a lazy cleanup
      in aes_cmac_128_final() via ZERO_STRUCTP(ctx)
    - We avoid unused memcpy() calls
    - We use the optimized aes_block_{xor,lshift}() functions
    - Align AES_BLOCK_SIZE arrays to 8 bytes
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 8795ad2030ade771145264be7c64d960dcfdbed7)

commit 3a633176302437e20286bbb5f70502b76584ecae
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 12 00:59:58 2015 +0200

    lib/crypto: add optimized helper functions aes_block_{xor,lshift,rshift}()
    
    These are typical operations on an AES_BLOCK used by different modes.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 0824221b4ae18e7ccba3f8057090abc925a02b99)

commit da29dc56b91550bda4807f79506bc3eb062a1a56
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 14 13:13:21 2015 +0200

    lib/crypto: add aes_ccm_128 tests
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 77c3d504b218c451c091a3d3cb4797a9d0c65d2a)

commit a4bc721154a35862dc08ab7c028d529cbe230fcc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 27 13:44:56 2015 +0200

    lib/crypto: verify 0 updates in aes_gcm_128 tests
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 80c8a1ca9577075d5917fb63ae820105cffebd57)

commit 33c7c5ae3c078728a80445bf87572af8cf24a05f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 14 13:12:13 2015 +0200

    lib/crypto: run all aes_gcm_128 testcases
    
    We should not skip the first one.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 683eda2f92cd296e36c57d96d6f0b22dde1819f4)

commit 862b204e865145e4616320607fc41d99ae0157bc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 11 16:31:25 2015 +0200

    lib/crypto: add aes_cmac_128 chunked tests
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 7c4117f5dadab8c52e15cb121f3c112a20b1646c)

commit c3ecf1464569de0f9f8ed53a10bd827ed96b19fd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 12 12:09:24 2015 +0200

    s3:vfs_smb_traffic_analyzer: remove samba_ prefix from AES_* function calls
    
    This should be an implementation detail in lib/crypto/aes.h.
    
    In future we may add support for other implementations.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 64c6cc34d7cdc48443a9427d2448ede9727aad47)

commit 8fc7a9a03466fef6c20081e5afb2ad03884fa6e0
Author: Günther Deschner <gd at samba.org>
Date:   Wed Jul 22 14:52:06 2015 +0200

    vfs: fix build warning in smb traffic analyzer.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 3d0b23dbd443381be1f265305ddda5434c0580aa)

commit ae3c0c84c0a8a9b5a3a6a44b281c6d3f9097520e
Author: Roel van Meer <roel at 1afa.com>
Date:   Tue Aug 4 16:50:43 2015 +0200

    s3-util: Compare the maximum allowed length of a NetBIOS name
    
    This fixes a problem where is_myname() returns true if one of our names
    is a substring of the specified name.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11427
    
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 4e178ed498c594ffcd5592d0b792d47b064b9586)

commit aca49d0e15701ead5df8674fc2506b462605a057
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Aug 19 16:19:30 2015 +0200

    s3-auth: Fix a memory leak in make_server_info_info3()
    
    We call make_server_info(NULL) and it is possible that we do not free
    it, because server_info is not allocated on the memory context we pass
    to the function.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=9862
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 6363c0232c2238e1a782e9c22ef762e3ff9b7563)

commit f5c6c894ce2b88c0a4a38377d0ebd3a14ff0e213
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Aug 19 16:24:08 2015 +0200

    s3-auth: Pass nt_username to check_account()
    
    We set nt_username above but do not use it in this function.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=9862
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit e8c76932e4ac192a00afa3b9731f5921c4b37da6)

commit 3271b5b14033896bf0d750965236de72e5a8b6d6
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Aug 19 16:11:47 2015 +0200

    s3-auth: Fix 'map to guest = Bad Uid' support
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=9862
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 34965d4d98d172e848e2b96fad8a9e0b99288ba7)

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

Summary of changes:
 lib/crypto/aes.c                           |  43 ++-
 lib/crypto/aes.h                           | 592 ++++++++++++++++++++++++++++-
 lib/crypto/aes_ccm_128.c                   | 117 +++---
 lib/crypto/aes_ccm_128.h                   |   8 +-
 lib/crypto/aes_ccm_128_test.c              | 376 ++++++++++++++++++
 lib/crypto/aes_cmac_128.c                  | 104 +----
 lib/crypto/aes_cmac_128.h                  |   6 +
 lib/crypto/aes_cmac_128_test.c             |  26 ++
 lib/crypto/aes_gcm_128.c                   |  46 +--
 lib/crypto/aes_gcm_128.h                   |  15 +-
 lib/crypto/aes_gcm_128_test.c              | 370 ++++++++----------
 lib/crypto/aes_test.h                      |  67 ++++
 lib/crypto/wscript_build                   |  11 +-
 librpc/idl/winbind.idl                     |   2 -
 source3/auth/auth_util.c                   |  48 ++-
 source3/include/proto.h                    |   9 +
 source3/lib/util.c                         |   2 +-
 source3/modules/vfs_smb_traffic_analyzer.c |   6 +-
 source3/modules/wscript_build              |   1 -
 source3/param/loadparm.c                   |  73 ++++
 source3/torture/test_idmap_tdb_common.c    |   2 +-
 source3/winbindd/idmap.c                   | 244 ++++++------
 source3/winbindd/idmap_proto.h             |   7 +-
 source3/winbindd/idmap_util.c              |  14 +-
 source3/winbindd/wb_gid2sid.c              |  15 +-
 source3/winbindd/wb_uid2sid.c              |  15 +-
 source3/winbindd/winbindd.h                |   7 -
 source3/winbindd/winbindd_dual_srv.c       |   6 +-
 source3/winbindd/winbindd_util.c           |  33 --
 source4/torture/local/local.c              |   2 +
 30 files changed, 1639 insertions(+), 628 deletions(-)
 create mode 100644 lib/crypto/aes_ccm_128_test.c
 create mode 100644 lib/crypto/aes_test.h


Changeset truncated at 500 lines:

diff --git a/lib/crypto/aes.c b/lib/crypto/aes.c
index a47a456..800a97e 100644
--- a/lib/crypto/aes.c
+++ b/lib/crypto/aes.c
@@ -32,9 +32,10 @@
  */
 
 #include "replace.h"
+#include "aes.h"
 
+#ifdef SAMBA_RIJNDAEL
 #include "rijndael-alg-fst.h"
-#include "aes.h"
 
 int
 AES_set_encrypt_key(const unsigned char *userkey, const int bits, AES_KEY *key)
@@ -65,7 +66,9 @@ AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key)
 {
     rijndaelDecrypt(key->key, key->rounds, in, out);
 }
+#endif /* SAMBA_RIJNDAEL */
 
+#ifdef SAMBA_AES_CBC_ENCRYPT
 void
 AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
 		unsigned long size, const AES_KEY *key,
@@ -112,25 +115,29 @@ AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
 	}
     }
 }
+#endif /* SAMBA_AES_CBC_ENCRYPT */
 
-void aes_cfb8_encrypt(const uint8_t *in, uint8_t *out,
-		      size_t length, const AES_KEY *key,
-		      uint8_t *iv, int forward)
+#ifdef SAMBA_AES_CFB8_ENCRYPT
+void
+AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
+                 unsigned long size, const AES_KEY *key,
+                 unsigned char *iv, int forward_encrypt)
 {
-	size_t i;
+    int i;
 
-	for (i=0; i < length; i++) {
-		uint8_t tiv[AES_BLOCK_SIZE*2];
+    for (i = 0; i < size; i++) {
+        unsigned char tmp[AES_BLOCK_SIZE + 1];
 
-		memcpy(tiv, iv, AES_BLOCK_SIZE);
-		AES_encrypt(iv, iv, key);
-		if (!forward) {
-			tiv[AES_BLOCK_SIZE] = in[i];
-		}
-		out[i] = in[i] ^ iv[0];
-		if (forward) {
-			tiv[AES_BLOCK_SIZE] = out[i];
-		}
-		memcpy(iv, tiv+1, AES_BLOCK_SIZE);
-	}
+        memcpy(tmp, iv, AES_BLOCK_SIZE);
+        AES_encrypt(iv, iv, key);
+        if (!forward_encrypt) {
+            tmp[AES_BLOCK_SIZE] = in[i];
+        }
+        out[i] = in[i] ^ iv[0];
+        if (forward_encrypt) {
+            tmp[AES_BLOCK_SIZE] = out[i];
+        }
+        memcpy(iv, &tmp[1], AES_BLOCK_SIZE);
+    }
 }
+#endif /* SAMBA_AES_CFB8_ENCRYPT */
diff --git a/lib/crypto/aes.h b/lib/crypto/aes.h
index a2b6c07..48ea764 100644
--- a/lib/crypto/aes.h
+++ b/lib/crypto/aes.h
@@ -36,12 +36,18 @@
 #ifndef LIB_CRYPTO_AES_H
 #define LIB_CRYPTO_AES_H 1
 
+#define SAMBA_RIJNDAEL 1
+#define SAMBA_AES_CBC_ENCRYPT 1
+#define SAMBA_AES_CFB8_ENCRYPT 1
+#define SAMBA_AES_BLOCK_XOR 1
+
 /* symbol renaming */
 #define AES_set_encrypt_key samba_AES_set_encrypt_key
 #define AES_set_decrypt_key samba_AES_decrypt_key
 #define AES_encrypt samba_AES_encrypt
 #define AES_decrypt samba_AES_decrypt
 #define AES_cbc_encrypt samba_AES_cbc_encrypt
+#define AES_cfb8_encrypt samba_AES_cfb8_encrypt
 
 /*
  *
@@ -72,12 +78,592 @@ void AES_cbc_encrypt(const unsigned char *, unsigned char *,
 		     const unsigned long, const AES_KEY *,
 		     unsigned char *, int);
 
-void aes_cfb8_encrypt(const uint8_t *in, uint8_t *out,
-		      size_t length, const AES_KEY *key,
-		      uint8_t *iv, int forward);
+void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
+		      unsigned long size, const AES_KEY *key,
+		      unsigned char *iv, int forward_encrypt);
+
+#define aes_cfb8_encrypt(in, out, size, key, iv, forward_encrypt) \
+	AES_cfb8_encrypt(in, out, size, key, iv, forward_encrypt)
 
 #ifdef  __cplusplus
 }
 #endif
 
+#ifdef SAMBA_AES_BLOCK_XOR
+static inline void aes_block_xor(const uint8_t in1[AES_BLOCK_SIZE],
+				 const uint8_t in2[AES_BLOCK_SIZE],
+				 uint8_t out[AES_BLOCK_SIZE])
+{
+#define __IS_ALIGN8(p) ((((uintptr_t)(p)) & 0x7) == 0)
+#define __IS_ALIGNED(a,b,c) __IS_ALIGN8(\
+		((uintptr_t)(a)) | \
+		((uintptr_t)(b)) | \
+		((uintptr_t)(c)))
+	/* If everything is aligned we can optimize */
+	if (likely(__IS_ALIGNED(in1, in2, out))) {
+#define __RO64(p) ((const uint64_t *)(p))
+#define __RW64(p) ((uint64_t *)(p))
+		__RW64(out)[0] = __RO64(in1)[0] ^ __RO64(in2)[0];
+		__RW64(out)[1] = __RO64(in1)[1] ^ __RO64(in2)[1];
+	} else {
+		uint64_t i1[2];
+		uint64_t i2[2];
+		uint64_t o[2];
+
+		memcpy(i1, in1, AES_BLOCK_SIZE);
+		memcpy(i2, in2, AES_BLOCK_SIZE);
+		o[0] = i1[0] ^ i2[0];
+		o[1] = i1[1] ^ i2[1];
+		memcpy(out, o, AES_BLOCK_SIZE);
+	}
+}
+#endif /* SAMBA_AES_BLOCK_XOR */
+
+static inline void aes_block_lshift(const uint8_t in[AES_BLOCK_SIZE],
+				    uint8_t out[AES_BLOCK_SIZE])
+{
+	static const struct aes_block_lshift_entry {
+		uint8_t lshift;
+		uint8_t overflow;
+	} aes_block_lshift_table[UINT8_MAX+1] = {
+		[0x00] = { .lshift = 0x00, .overflow = 0x00 },
+		[0x01] = { .lshift = 0x02, .overflow = 0x00 },
+		[0x02] = { .lshift = 0x04, .overflow = 0x00 },
+		[0x03] = { .lshift = 0x06, .overflow = 0x00 },
+		[0x04] = { .lshift = 0x08, .overflow = 0x00 },
+		[0x05] = { .lshift = 0x0a, .overflow = 0x00 },
+		[0x06] = { .lshift = 0x0c, .overflow = 0x00 },
+		[0x07] = { .lshift = 0x0e, .overflow = 0x00 },
+		[0x08] = { .lshift = 0x10, .overflow = 0x00 },
+		[0x09] = { .lshift = 0x12, .overflow = 0x00 },
+		[0x0a] = { .lshift = 0x14, .overflow = 0x00 },
+		[0x0b] = { .lshift = 0x16, .overflow = 0x00 },
+		[0x0c] = { .lshift = 0x18, .overflow = 0x00 },
+		[0x0d] = { .lshift = 0x1a, .overflow = 0x00 },
+		[0x0e] = { .lshift = 0x1c, .overflow = 0x00 },
+		[0x0f] = { .lshift = 0x1e, .overflow = 0x00 },
+		[0x10] = { .lshift = 0x20, .overflow = 0x00 },
+		[0x11] = { .lshift = 0x22, .overflow = 0x00 },
+		[0x12] = { .lshift = 0x24, .overflow = 0x00 },
+		[0x13] = { .lshift = 0x26, .overflow = 0x00 },
+		[0x14] = { .lshift = 0x28, .overflow = 0x00 },
+		[0x15] = { .lshift = 0x2a, .overflow = 0x00 },
+		[0x16] = { .lshift = 0x2c, .overflow = 0x00 },
+		[0x17] = { .lshift = 0x2e, .overflow = 0x00 },
+		[0x18] = { .lshift = 0x30, .overflow = 0x00 },
+		[0x19] = { .lshift = 0x32, .overflow = 0x00 },
+		[0x1a] = { .lshift = 0x34, .overflow = 0x00 },
+		[0x1b] = { .lshift = 0x36, .overflow = 0x00 },
+		[0x1c] = { .lshift = 0x38, .overflow = 0x00 },
+		[0x1d] = { .lshift = 0x3a, .overflow = 0x00 },
+		[0x1e] = { .lshift = 0x3c, .overflow = 0x00 },
+		[0x1f] = { .lshift = 0x3e, .overflow = 0x00 },
+		[0x20] = { .lshift = 0x40, .overflow = 0x00 },
+		[0x21] = { .lshift = 0x42, .overflow = 0x00 },
+		[0x22] = { .lshift = 0x44, .overflow = 0x00 },
+		[0x23] = { .lshift = 0x46, .overflow = 0x00 },
+		[0x24] = { .lshift = 0x48, .overflow = 0x00 },
+		[0x25] = { .lshift = 0x4a, .overflow = 0x00 },
+		[0x26] = { .lshift = 0x4c, .overflow = 0x00 },
+		[0x27] = { .lshift = 0x4e, .overflow = 0x00 },
+		[0x28] = { .lshift = 0x50, .overflow = 0x00 },
+		[0x29] = { .lshift = 0x52, .overflow = 0x00 },
+		[0x2a] = { .lshift = 0x54, .overflow = 0x00 },
+		[0x2b] = { .lshift = 0x56, .overflow = 0x00 },
+		[0x2c] = { .lshift = 0x58, .overflow = 0x00 },
+		[0x2d] = { .lshift = 0x5a, .overflow = 0x00 },
+		[0x2e] = { .lshift = 0x5c, .overflow = 0x00 },
+		[0x2f] = { .lshift = 0x5e, .overflow = 0x00 },
+		[0x30] = { .lshift = 0x60, .overflow = 0x00 },
+		[0x31] = { .lshift = 0x62, .overflow = 0x00 },
+		[0x32] = { .lshift = 0x64, .overflow = 0x00 },
+		[0x33] = { .lshift = 0x66, .overflow = 0x00 },
+		[0x34] = { .lshift = 0x68, .overflow = 0x00 },
+		[0x35] = { .lshift = 0x6a, .overflow = 0x00 },
+		[0x36] = { .lshift = 0x6c, .overflow = 0x00 },
+		[0x37] = { .lshift = 0x6e, .overflow = 0x00 },
+		[0x38] = { .lshift = 0x70, .overflow = 0x00 },
+		[0x39] = { .lshift = 0x72, .overflow = 0x00 },
+		[0x3a] = { .lshift = 0x74, .overflow = 0x00 },
+		[0x3b] = { .lshift = 0x76, .overflow = 0x00 },
+		[0x3c] = { .lshift = 0x78, .overflow = 0x00 },
+		[0x3d] = { .lshift = 0x7a, .overflow = 0x00 },
+		[0x3e] = { .lshift = 0x7c, .overflow = 0x00 },
+		[0x3f] = { .lshift = 0x7e, .overflow = 0x00 },
+		[0x40] = { .lshift = 0x80, .overflow = 0x00 },
+		[0x41] = { .lshift = 0x82, .overflow = 0x00 },
+		[0x42] = { .lshift = 0x84, .overflow = 0x00 },
+		[0x43] = { .lshift = 0x86, .overflow = 0x00 },
+		[0x44] = { .lshift = 0x88, .overflow = 0x00 },
+		[0x45] = { .lshift = 0x8a, .overflow = 0x00 },
+		[0x46] = { .lshift = 0x8c, .overflow = 0x00 },
+		[0x47] = { .lshift = 0x8e, .overflow = 0x00 },
+		[0x48] = { .lshift = 0x90, .overflow = 0x00 },
+		[0x49] = { .lshift = 0x92, .overflow = 0x00 },
+		[0x4a] = { .lshift = 0x94, .overflow = 0x00 },
+		[0x4b] = { .lshift = 0x96, .overflow = 0x00 },
+		[0x4c] = { .lshift = 0x98, .overflow = 0x00 },
+		[0x4d] = { .lshift = 0x9a, .overflow = 0x00 },
+		[0x4e] = { .lshift = 0x9c, .overflow = 0x00 },
+		[0x4f] = { .lshift = 0x9e, .overflow = 0x00 },
+		[0x50] = { .lshift = 0xa0, .overflow = 0x00 },
+		[0x51] = { .lshift = 0xa2, .overflow = 0x00 },
+		[0x52] = { .lshift = 0xa4, .overflow = 0x00 },
+		[0x53] = { .lshift = 0xa6, .overflow = 0x00 },
+		[0x54] = { .lshift = 0xa8, .overflow = 0x00 },
+		[0x55] = { .lshift = 0xaa, .overflow = 0x00 },
+		[0x56] = { .lshift = 0xac, .overflow = 0x00 },
+		[0x57] = { .lshift = 0xae, .overflow = 0x00 },
+		[0x58] = { .lshift = 0xb0, .overflow = 0x00 },
+		[0x59] = { .lshift = 0xb2, .overflow = 0x00 },
+		[0x5a] = { .lshift = 0xb4, .overflow = 0x00 },
+		[0x5b] = { .lshift = 0xb6, .overflow = 0x00 },
+		[0x5c] = { .lshift = 0xb8, .overflow = 0x00 },
+		[0x5d] = { .lshift = 0xba, .overflow = 0x00 },
+		[0x5e] = { .lshift = 0xbc, .overflow = 0x00 },
+		[0x5f] = { .lshift = 0xbe, .overflow = 0x00 },
+		[0x60] = { .lshift = 0xc0, .overflow = 0x00 },
+		[0x61] = { .lshift = 0xc2, .overflow = 0x00 },
+		[0x62] = { .lshift = 0xc4, .overflow = 0x00 },
+		[0x63] = { .lshift = 0xc6, .overflow = 0x00 },
+		[0x64] = { .lshift = 0xc8, .overflow = 0x00 },
+		[0x65] = { .lshift = 0xca, .overflow = 0x00 },
+		[0x66] = { .lshift = 0xcc, .overflow = 0x00 },
+		[0x67] = { .lshift = 0xce, .overflow = 0x00 },
+		[0x68] = { .lshift = 0xd0, .overflow = 0x00 },
+		[0x69] = { .lshift = 0xd2, .overflow = 0x00 },
+		[0x6a] = { .lshift = 0xd4, .overflow = 0x00 },
+		[0x6b] = { .lshift = 0xd6, .overflow = 0x00 },
+		[0x6c] = { .lshift = 0xd8, .overflow = 0x00 },
+		[0x6d] = { .lshift = 0xda, .overflow = 0x00 },
+		[0x6e] = { .lshift = 0xdc, .overflow = 0x00 },
+		[0x6f] = { .lshift = 0xde, .overflow = 0x00 },
+		[0x70] = { .lshift = 0xe0, .overflow = 0x00 },
+		[0x71] = { .lshift = 0xe2, .overflow = 0x00 },
+		[0x72] = { .lshift = 0xe4, .overflow = 0x00 },
+		[0x73] = { .lshift = 0xe6, .overflow = 0x00 },
+		[0x74] = { .lshift = 0xe8, .overflow = 0x00 },
+		[0x75] = { .lshift = 0xea, .overflow = 0x00 },
+		[0x76] = { .lshift = 0xec, .overflow = 0x00 },
+		[0x77] = { .lshift = 0xee, .overflow = 0x00 },
+		[0x78] = { .lshift = 0xf0, .overflow = 0x00 },
+		[0x79] = { .lshift = 0xf2, .overflow = 0x00 },
+		[0x7a] = { .lshift = 0xf4, .overflow = 0x00 },
+		[0x7b] = { .lshift = 0xf6, .overflow = 0x00 },
+		[0x7c] = { .lshift = 0xf8, .overflow = 0x00 },
+		[0x7d] = { .lshift = 0xfa, .overflow = 0x00 },
+		[0x7e] = { .lshift = 0xfc, .overflow = 0x00 },
+		[0x7f] = { .lshift = 0xfe, .overflow = 0x00 },
+		[0x80] = { .lshift = 0x00, .overflow = 0x01 },
+		[0x81] = { .lshift = 0x02, .overflow = 0x01 },
+		[0x82] = { .lshift = 0x04, .overflow = 0x01 },
+		[0x83] = { .lshift = 0x06, .overflow = 0x01 },
+		[0x84] = { .lshift = 0x08, .overflow = 0x01 },
+		[0x85] = { .lshift = 0x0a, .overflow = 0x01 },
+		[0x86] = { .lshift = 0x0c, .overflow = 0x01 },
+		[0x87] = { .lshift = 0x0e, .overflow = 0x01 },
+		[0x88] = { .lshift = 0x10, .overflow = 0x01 },
+		[0x89] = { .lshift = 0x12, .overflow = 0x01 },
+		[0x8a] = { .lshift = 0x14, .overflow = 0x01 },
+		[0x8b] = { .lshift = 0x16, .overflow = 0x01 },
+		[0x8c] = { .lshift = 0x18, .overflow = 0x01 },
+		[0x8d] = { .lshift = 0x1a, .overflow = 0x01 },
+		[0x8e] = { .lshift = 0x1c, .overflow = 0x01 },
+		[0x8f] = { .lshift = 0x1e, .overflow = 0x01 },
+		[0x90] = { .lshift = 0x20, .overflow = 0x01 },
+		[0x91] = { .lshift = 0x22, .overflow = 0x01 },
+		[0x92] = { .lshift = 0x24, .overflow = 0x01 },
+		[0x93] = { .lshift = 0x26, .overflow = 0x01 },
+		[0x94] = { .lshift = 0x28, .overflow = 0x01 },
+		[0x95] = { .lshift = 0x2a, .overflow = 0x01 },
+		[0x96] = { .lshift = 0x2c, .overflow = 0x01 },
+		[0x97] = { .lshift = 0x2e, .overflow = 0x01 },
+		[0x98] = { .lshift = 0x30, .overflow = 0x01 },
+		[0x99] = { .lshift = 0x32, .overflow = 0x01 },
+		[0x9a] = { .lshift = 0x34, .overflow = 0x01 },
+		[0x9b] = { .lshift = 0x36, .overflow = 0x01 },
+		[0x9c] = { .lshift = 0x38, .overflow = 0x01 },
+		[0x9d] = { .lshift = 0x3a, .overflow = 0x01 },
+		[0x9e] = { .lshift = 0x3c, .overflow = 0x01 },
+		[0x9f] = { .lshift = 0x3e, .overflow = 0x01 },
+		[0xa0] = { .lshift = 0x40, .overflow = 0x01 },
+		[0xa1] = { .lshift = 0x42, .overflow = 0x01 },
+		[0xa2] = { .lshift = 0x44, .overflow = 0x01 },
+		[0xa3] = { .lshift = 0x46, .overflow = 0x01 },
+		[0xa4] = { .lshift = 0x48, .overflow = 0x01 },
+		[0xa5] = { .lshift = 0x4a, .overflow = 0x01 },
+		[0xa6] = { .lshift = 0x4c, .overflow = 0x01 },
+		[0xa7] = { .lshift = 0x4e, .overflow = 0x01 },
+		[0xa8] = { .lshift = 0x50, .overflow = 0x01 },
+		[0xa9] = { .lshift = 0x52, .overflow = 0x01 },
+		[0xaa] = { .lshift = 0x54, .overflow = 0x01 },
+		[0xab] = { .lshift = 0x56, .overflow = 0x01 },
+		[0xac] = { .lshift = 0x58, .overflow = 0x01 },
+		[0xad] = { .lshift = 0x5a, .overflow = 0x01 },
+		[0xae] = { .lshift = 0x5c, .overflow = 0x01 },
+		[0xaf] = { .lshift = 0x5e, .overflow = 0x01 },
+		[0xb0] = { .lshift = 0x60, .overflow = 0x01 },
+		[0xb1] = { .lshift = 0x62, .overflow = 0x01 },
+		[0xb2] = { .lshift = 0x64, .overflow = 0x01 },
+		[0xb3] = { .lshift = 0x66, .overflow = 0x01 },
+		[0xb4] = { .lshift = 0x68, .overflow = 0x01 },
+		[0xb5] = { .lshift = 0x6a, .overflow = 0x01 },
+		[0xb6] = { .lshift = 0x6c, .overflow = 0x01 },
+		[0xb7] = { .lshift = 0x6e, .overflow = 0x01 },
+		[0xb8] = { .lshift = 0x70, .overflow = 0x01 },
+		[0xb9] = { .lshift = 0x72, .overflow = 0x01 },
+		[0xba] = { .lshift = 0x74, .overflow = 0x01 },
+		[0xbb] = { .lshift = 0x76, .overflow = 0x01 },
+		[0xbc] = { .lshift = 0x78, .overflow = 0x01 },
+		[0xbd] = { .lshift = 0x7a, .overflow = 0x01 },
+		[0xbe] = { .lshift = 0x7c, .overflow = 0x01 },
+		[0xbf] = { .lshift = 0x7e, .overflow = 0x01 },
+		[0xc0] = { .lshift = 0x80, .overflow = 0x01 },
+		[0xc1] = { .lshift = 0x82, .overflow = 0x01 },
+		[0xc2] = { .lshift = 0x84, .overflow = 0x01 },
+		[0xc3] = { .lshift = 0x86, .overflow = 0x01 },
+		[0xc4] = { .lshift = 0x88, .overflow = 0x01 },
+		[0xc5] = { .lshift = 0x8a, .overflow = 0x01 },
+		[0xc6] = { .lshift = 0x8c, .overflow = 0x01 },
+		[0xc7] = { .lshift = 0x8e, .overflow = 0x01 },
+		[0xc8] = { .lshift = 0x90, .overflow = 0x01 },
+		[0xc9] = { .lshift = 0x92, .overflow = 0x01 },
+		[0xca] = { .lshift = 0x94, .overflow = 0x01 },
+		[0xcb] = { .lshift = 0x96, .overflow = 0x01 },
+		[0xcc] = { .lshift = 0x98, .overflow = 0x01 },
+		[0xcd] = { .lshift = 0x9a, .overflow = 0x01 },
+		[0xce] = { .lshift = 0x9c, .overflow = 0x01 },
+		[0xcf] = { .lshift = 0x9e, .overflow = 0x01 },
+		[0xd0] = { .lshift = 0xa0, .overflow = 0x01 },
+		[0xd1] = { .lshift = 0xa2, .overflow = 0x01 },
+		[0xd2] = { .lshift = 0xa4, .overflow = 0x01 },
+		[0xd3] = { .lshift = 0xa6, .overflow = 0x01 },
+		[0xd4] = { .lshift = 0xa8, .overflow = 0x01 },
+		[0xd5] = { .lshift = 0xaa, .overflow = 0x01 },
+		[0xd6] = { .lshift = 0xac, .overflow = 0x01 },
+		[0xd7] = { .lshift = 0xae, .overflow = 0x01 },
+		[0xd8] = { .lshift = 0xb0, .overflow = 0x01 },
+		[0xd9] = { .lshift = 0xb2, .overflow = 0x01 },
+		[0xda] = { .lshift = 0xb4, .overflow = 0x01 },
+		[0xdb] = { .lshift = 0xb6, .overflow = 0x01 },
+		[0xdc] = { .lshift = 0xb8, .overflow = 0x01 },
+		[0xdd] = { .lshift = 0xba, .overflow = 0x01 },
+		[0xde] = { .lshift = 0xbc, .overflow = 0x01 },
+		[0xdf] = { .lshift = 0xbe, .overflow = 0x01 },
+		[0xe0] = { .lshift = 0xc0, .overflow = 0x01 },
+		[0xe1] = { .lshift = 0xc2, .overflow = 0x01 },
+		[0xe2] = { .lshift = 0xc4, .overflow = 0x01 },
+		[0xe3] = { .lshift = 0xc6, .overflow = 0x01 },
+		[0xe4] = { .lshift = 0xc8, .overflow = 0x01 },
+		[0xe5] = { .lshift = 0xca, .overflow = 0x01 },
+		[0xe6] = { .lshift = 0xcc, .overflow = 0x01 },
+		[0xe7] = { .lshift = 0xce, .overflow = 0x01 },
+		[0xe8] = { .lshift = 0xd0, .overflow = 0x01 },
+		[0xe9] = { .lshift = 0xd2, .overflow = 0x01 },
+		[0xea] = { .lshift = 0xd4, .overflow = 0x01 },
+		[0xeb] = { .lshift = 0xd6, .overflow = 0x01 },
+		[0xec] = { .lshift = 0xd8, .overflow = 0x01 },
+		[0xed] = { .lshift = 0xda, .overflow = 0x01 },
+		[0xee] = { .lshift = 0xdc, .overflow = 0x01 },
+		[0xef] = { .lshift = 0xde, .overflow = 0x01 },
+		[0xf0] = { .lshift = 0xe0, .overflow = 0x01 },
+		[0xf1] = { .lshift = 0xe2, .overflow = 0x01 },
+		[0xf2] = { .lshift = 0xe4, .overflow = 0x01 },
+		[0xf3] = { .lshift = 0xe6, .overflow = 0x01 },
+		[0xf4] = { .lshift = 0xe8, .overflow = 0x01 },
+		[0xf5] = { .lshift = 0xea, .overflow = 0x01 },
+		[0xf6] = { .lshift = 0xec, .overflow = 0x01 },
+		[0xf7] = { .lshift = 0xee, .overflow = 0x01 },
+		[0xf8] = { .lshift = 0xf0, .overflow = 0x01 },
+		[0xf9] = { .lshift = 0xf2, .overflow = 0x01 },
+		[0xfa] = { .lshift = 0xf4, .overflow = 0x01 },
+		[0xfb] = { .lshift = 0xf6, .overflow = 0x01 },
+		[0xfc] = { .lshift = 0xf8, .overflow = 0x01 },
+		[0xfd] = { .lshift = 0xfa, .overflow = 0x01 },
+		[0xfe] = { .lshift = 0xfc, .overflow = 0x01 },
+		[0xff] = { .lshift = 0xfe, .overflow = 0x01 },
+	};
+	int8_t i;
+	uint8_t overflow = 0;
+
+	for (i = AES_BLOCK_SIZE - 1; i >= 0; i--) {
+		const struct aes_block_lshift_entry *e = &aes_block_lshift_table[in[i]];
+		out[i] = e->lshift | overflow;
+		overflow = e->overflow;
+	}
+}
+
+static inline void aes_block_rshift(const uint8_t in[AES_BLOCK_SIZE],
+				    uint8_t out[AES_BLOCK_SIZE])
+{
+	static const struct aes_block_rshift_entry {
+		uint8_t rshift;
+		uint8_t overflow;
+	} aes_block_rshift_table[UINT8_MAX+1] = {
+		[0x00] = { .rshift = 0x00, .overflow = 0x00 },
+		[0x01] = { .rshift = 0x00, .overflow = 0x80 },
+		[0x02] = { .rshift = 0x01, .overflow = 0x00 },
+		[0x03] = { .rshift = 0x01, .overflow = 0x80 },
+		[0x04] = { .rshift = 0x02, .overflow = 0x00 },
+		[0x05] = { .rshift = 0x02, .overflow = 0x80 },
+		[0x06] = { .rshift = 0x03, .overflow = 0x00 },
+		[0x07] = { .rshift = 0x03, .overflow = 0x80 },
+		[0x08] = { .rshift = 0x04, .overflow = 0x00 },
+		[0x09] = { .rshift = 0x04, .overflow = 0x80 },
+		[0x0a] = { .rshift = 0x05, .overflow = 0x00 },
+		[0x0b] = { .rshift = 0x05, .overflow = 0x80 },
+		[0x0c] = { .rshift = 0x06, .overflow = 0x00 },
+		[0x0d] = { .rshift = 0x06, .overflow = 0x80 },
+		[0x0e] = { .rshift = 0x07, .overflow = 0x00 },
+		[0x0f] = { .rshift = 0x07, .overflow = 0x80 },
+		[0x10] = { .rshift = 0x08, .overflow = 0x00 },
+		[0x11] = { .rshift = 0x08, .overflow = 0x80 },
+		[0x12] = { .rshift = 0x09, .overflow = 0x00 },
+		[0x13] = { .rshift = 0x09, .overflow = 0x80 },
+		[0x14] = { .rshift = 0x0a, .overflow = 0x00 },
+		[0x15] = { .rshift = 0x0a, .overflow = 0x80 },
+		[0x16] = { .rshift = 0x0b, .overflow = 0x00 },
+		[0x17] = { .rshift = 0x0b, .overflow = 0x80 },
+		[0x18] = { .rshift = 0x0c, .overflow = 0x00 },
+		[0x19] = { .rshift = 0x0c, .overflow = 0x80 },
+		[0x1a] = { .rshift = 0x0d, .overflow = 0x00 },
+		[0x1b] = { .rshift = 0x0d, .overflow = 0x80 },
+		[0x1c] = { .rshift = 0x0e, .overflow = 0x00 },
+		[0x1d] = { .rshift = 0x0e, .overflow = 0x80 },
+		[0x1e] = { .rshift = 0x0f, .overflow = 0x00 },
+		[0x1f] = { .rshift = 0x0f, .overflow = 0x80 },
+		[0x20] = { .rshift = 0x10, .overflow = 0x00 },
+		[0x21] = { .rshift = 0x10, .overflow = 0x80 },
+		[0x22] = { .rshift = 0x11, .overflow = 0x00 },
+		[0x23] = { .rshift = 0x11, .overflow = 0x80 },
+		[0x24] = { .rshift = 0x12, .overflow = 0x00 },
+		[0x25] = { .rshift = 0x12, .overflow = 0x80 },
+		[0x26] = { .rshift = 0x13, .overflow = 0x00 },
+		[0x27] = { .rshift = 0x13, .overflow = 0x80 },
+		[0x28] = { .rshift = 0x14, .overflow = 0x00 },
+		[0x29] = { .rshift = 0x14, .overflow = 0x80 },
+		[0x2a] = { .rshift = 0x15, .overflow = 0x00 },
+		[0x2b] = { .rshift = 0x15, .overflow = 0x80 },
+		[0x2c] = { .rshift = 0x16, .overflow = 0x00 },
+		[0x2d] = { .rshift = 0x16, .overflow = 0x80 },
+		[0x2e] = { .rshift = 0x17, .overflow = 0x00 },
+		[0x2f] = { .rshift = 0x17, .overflow = 0x80 },
+		[0x30] = { .rshift = 0x18, .overflow = 0x00 },
+		[0x31] = { .rshift = 0x18, .overflow = 0x80 },
+		[0x32] = { .rshift = 0x19, .overflow = 0x00 },
+		[0x33] = { .rshift = 0x19, .overflow = 0x80 },
+		[0x34] = { .rshift = 0x1a, .overflow = 0x00 },
+		[0x35] = { .rshift = 0x1a, .overflow = 0x80 },
+		[0x36] = { .rshift = 0x1b, .overflow = 0x00 },
+		[0x37] = { .rshift = 0x1b, .overflow = 0x80 },
+		[0x38] = { .rshift = 0x1c, .overflow = 0x00 },
+		[0x39] = { .rshift = 0x1c, .overflow = 0x80 },
+		[0x3a] = { .rshift = 0x1d, .overflow = 0x00 },
+		[0x3b] = { .rshift = 0x1d, .overflow = 0x80 },
+		[0x3c] = { .rshift = 0x1e, .overflow = 0x00 },
+		[0x3d] = { .rshift = 0x1e, .overflow = 0x80 },
+		[0x3e] = { .rshift = 0x1f, .overflow = 0x00 },
+		[0x3f] = { .rshift = 0x1f, .overflow = 0x80 },
+		[0x40] = { .rshift = 0x20, .overflow = 0x00 },
+		[0x41] = { .rshift = 0x20, .overflow = 0x80 },
+		[0x42] = { .rshift = 0x21, .overflow = 0x00 },
+		[0x43] = { .rshift = 0x21, .overflow = 0x80 },
+		[0x44] = { .rshift = 0x22, .overflow = 0x00 },
+		[0x45] = { .rshift = 0x22, .overflow = 0x80 },
+		[0x46] = { .rshift = 0x23, .overflow = 0x00 },
+		[0x47] = { .rshift = 0x23, .overflow = 0x80 },
+		[0x48] = { .rshift = 0x24, .overflow = 0x00 },
+		[0x49] = { .rshift = 0x24, .overflow = 0x80 },
+		[0x4a] = { .rshift = 0x25, .overflow = 0x00 },


-- 
Samba Shared Repository



More information about the samba-cvs mailing list