Print this page
6436 156 lint errors in common/crypto/edonr/edonr.c


   6  * The contents of this file are subject to the terms of the
   7  * Common Development and Distribution License (the "License").
   8  * You may not use this file except in compliance with the License.
   9  *
  10  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11  * or http://opensource.org/licenses/CDDL-1.0.
  12  * See the License for the specific language governing permissions
  13  * and limitations under the License.
  14  *
  15  * When distributing Covered Code, include this CDDL HEADER in each
  16  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17  * If applicable, add the following below this CDDL HEADER, with the
  18  * fields enclosed by brackets "[]" replaced with your own identifying
  19  * information: Portions Copyright [yyyy] [name of copyright owner]
  20  *
  21  * CDDL HEADER END
  22  *
  23  * Copyright (C) 2009, 2010, Jorn Amundsen <jorn.amundsen@ntnu.no>
  24  * Tweaked Edon-R implementation for SUPERCOP, based on NIST API.
  25  *
  26  * $Id: edonr.c 517 2013-02-17 20:34:39Z joern $
  27  */
  28 /*
  29  * Portions copyright (c) 2013, Saso Kiselkov, All rights reserved

  30  */
  31 
  32 /* determine where we can get bcopy/bzero declarations */
  33 #ifdef  _KERNEL
  34 #include <sys/systm.h>
  35 #else
  36 #include <strings.h>
  37 #endif
  38 #include <sys/edonr.h>
  39 #include <sys/debug.h>
  40 
  41 /* big endian support, provides no-op's if run on little endian hosts */
  42 #include "edonr_byteorder.h"
  43 
  44 #define hashState224(x) ((x)->pipe->p256)
  45 #define hashState256(x) ((x)->pipe->p256)
  46 #define hashState384(x) ((x)->pipe->p512)
  47 #define hashState512(x) ((x)->pipe->p512)
  48 
  49 /* shift and rotate shortcuts */


 642                 } else {
 643                         (void) memset((hashState512(state)->LastPart) +
 644                             LastByte + 1, 0x00,
 645                             EdonR512_BLOCK_SIZE * 2 - LastByte - 9);
 646                         databitlen = EdonR512_BLOCK_SIZE * 16;
 647 #if defined(MACHINE_IS_BIG_ENDIAN)
 648                         st_swap64(num_bits, data64 + 31);
 649 #else
 650                         data64[31] = num_bits;
 651 #endif
 652                 }
 653 
 654                 state->bits_processed += Q512(databitlen, data64,
 655                     hashState512(state)->DoublePipe);
 656                 break;
 657         }
 658 
 659         switch (state->hashbitlen) {
 660         case 224: {
 661 #if defined(MACHINE_IS_BIG_ENDIAN)

 662                 uint32_t *d32 = (uint32_t *)hashval;
 663                 uint32_t *s32 = hashState224(state)->DoublePipe + 9;
 664                 int j;
 665 
 666                 for (j = 0; j < EdonR224_DIGEST_SIZE >> 2; j++)
 667                         st_swap32(s32[j], d32 + j);
 668 #else
 669                 bcopy(hashState256(state)->DoublePipe + 9, hashval,
 670                     EdonR224_DIGEST_SIZE);
 671 #endif
 672                 break;
 673         }
 674         case 256: {
 675 #if defined(MACHINE_IS_BIG_ENDIAN)

 676                 uint32_t *d32 = (uint32_t *)hashval;
 677                 uint32_t *s32 = hashState224(state)->DoublePipe + 8;
 678                 int j;
 679 
 680                 for (j = 0; j < EdonR256_DIGEST_SIZE >> 2; j++)
 681                         st_swap32(s32[j], d32 + j);
 682 #else
 683                 bcopy(hashState256(state)->DoublePipe + 8, hashval,
 684                     EdonR256_DIGEST_SIZE);
 685 #endif
 686                 break;
 687         }
 688         case 384: {
 689 #if defined(MACHINE_IS_BIG_ENDIAN)

 690                 uint64_t *d64 = (uint64_t *)hashval;
 691                 uint64_t *s64 = hashState384(state)->DoublePipe + 10;
 692                 int j;
 693 
 694                 for (j = 0; j < EdonR384_DIGEST_SIZE >> 3; j++)
 695                         st_swap64(s64[j], d64 + j);
 696 #else
 697                 bcopy(hashState384(state)->DoublePipe + 10, hashval,
 698                     EdonR384_DIGEST_SIZE);
 699 #endif
 700                 break;
 701         }
 702         case 512: {
 703 #if defined(MACHINE_IS_BIG_ENDIAN)

 704                 uint64_t *d64 = (uint64_t *)hashval;
 705                 uint64_t *s64 = hashState512(state)->DoublePipe + 8;
 706                 int j;
 707 
 708                 for (j = 0; j < EdonR512_DIGEST_SIZE >> 3; j++)
 709                         st_swap64(s64[j], d64 + j);
 710 #else
 711                 bcopy(hashState512(state)->DoublePipe + 8, hashval,
 712                     EdonR512_DIGEST_SIZE);
 713 #endif
 714                 break;
 715         }
 716         }
 717 }
 718 
 719 
 720 void
 721 EdonRHash(size_t hashbitlen, const uint8_t *data, size_t databitlen,
 722     uint8_t *hashval)
 723 {


   6  * The contents of this file are subject to the terms of the
   7  * Common Development and Distribution License (the "License").
   8  * You may not use this file except in compliance with the License.
   9  *
  10  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11  * or http://opensource.org/licenses/CDDL-1.0.
  12  * See the License for the specific language governing permissions
  13  * and limitations under the License.
  14  *
  15  * When distributing Covered Code, include this CDDL HEADER in each
  16  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17  * If applicable, add the following below this CDDL HEADER, with the
  18  * fields enclosed by brackets "[]" replaced with your own identifying
  19  * information: Portions Copyright [yyyy] [name of copyright owner]
  20  *
  21  * CDDL HEADER END
  22  *
  23  * Copyright (C) 2009, 2010, Jorn Amundsen <jorn.amundsen@ntnu.no>
  24  * Tweaked Edon-R implementation for SUPERCOP, based on NIST API.
  25  *

  26  */
  27 /*
  28  * Portions copyright (c) 2013, Saso Kiselkov, All rights reserved
  29  * Copyright 2016 Gary Mills
  30  */
  31 
  32 /* determine where we can get bcopy/bzero declarations */
  33 #ifdef  _KERNEL
  34 #include <sys/systm.h>
  35 #else
  36 #include <strings.h>
  37 #endif
  38 #include <sys/edonr.h>
  39 #include <sys/debug.h>
  40 
  41 /* big endian support, provides no-op's if run on little endian hosts */
  42 #include "edonr_byteorder.h"
  43 
  44 #define hashState224(x) ((x)->pipe->p256)
  45 #define hashState256(x) ((x)->pipe->p256)
  46 #define hashState384(x) ((x)->pipe->p512)
  47 #define hashState512(x) ((x)->pipe->p512)
  48 
  49 /* shift and rotate shortcuts */


 642                 } else {
 643                         (void) memset((hashState512(state)->LastPart) +
 644                             LastByte + 1, 0x00,
 645                             EdonR512_BLOCK_SIZE * 2 - LastByte - 9);
 646                         databitlen = EdonR512_BLOCK_SIZE * 16;
 647 #if defined(MACHINE_IS_BIG_ENDIAN)
 648                         st_swap64(num_bits, data64 + 31);
 649 #else
 650                         data64[31] = num_bits;
 651 #endif
 652                 }
 653 
 654                 state->bits_processed += Q512(databitlen, data64,
 655                     hashState512(state)->DoublePipe);
 656                 break;
 657         }
 658 
 659         switch (state->hashbitlen) {
 660         case 224: {
 661 #if defined(MACHINE_IS_BIG_ENDIAN)
 662                 /* LINTED: pointer cast may result in improper alignment */
 663                 uint32_t *d32 = (uint32_t *)hashval;
 664                 uint32_t *s32 = hashState224(state)->DoublePipe + 9;
 665                 int j;
 666 
 667                 for (j = 0; j < EdonR224_DIGEST_SIZE >> 2; j++)
 668                         st_swap32(s32[j], d32 + j);
 669 #else
 670                 bcopy(hashState256(state)->DoublePipe + 9, hashval,
 671                     EdonR224_DIGEST_SIZE);
 672 #endif
 673                 break;
 674         }
 675         case 256: {
 676 #if defined(MACHINE_IS_BIG_ENDIAN)
 677                 /* LINTED: pointer cast may result in improper alignment */
 678                 uint32_t *d32 = (uint32_t *)hashval;
 679                 uint32_t *s32 = hashState224(state)->DoublePipe + 8;
 680                 int j;
 681 
 682                 for (j = 0; j < EdonR256_DIGEST_SIZE >> 2; j++)
 683                         st_swap32(s32[j], d32 + j);
 684 #else
 685                 bcopy(hashState256(state)->DoublePipe + 8, hashval,
 686                     EdonR256_DIGEST_SIZE);
 687 #endif
 688                 break;
 689         }
 690         case 384: {
 691 #if defined(MACHINE_IS_BIG_ENDIAN)
 692                 /* LINTED: pointer cast may result in improper alignment */
 693                 uint64_t *d64 = (uint64_t *)hashval;
 694                 uint64_t *s64 = hashState384(state)->DoublePipe + 10;
 695                 int j;
 696 
 697                 for (j = 0; j < EdonR384_DIGEST_SIZE >> 3; j++)
 698                         st_swap64(s64[j], d64 + j);
 699 #else
 700                 bcopy(hashState384(state)->DoublePipe + 10, hashval,
 701                     EdonR384_DIGEST_SIZE);
 702 #endif
 703                 break;
 704         }
 705         case 512: {
 706 #if defined(MACHINE_IS_BIG_ENDIAN)
 707                 /* LINTED: pointer cast may result in improper alignment */
 708                 uint64_t *d64 = (uint64_t *)hashval;
 709                 uint64_t *s64 = hashState512(state)->DoublePipe + 8;
 710                 int j;
 711 
 712                 for (j = 0; j < EdonR512_DIGEST_SIZE >> 3; j++)
 713                         st_swap64(s64[j], d64 + j);
 714 #else
 715                 bcopy(hashState512(state)->DoublePipe + 8, hashval,
 716                     EdonR512_DIGEST_SIZE);
 717 #endif
 718                 break;
 719         }
 720         }
 721 }
 722 
 723 
 724 void
 725 EdonRHash(size_t hashbitlen, const uint8_t *data, size_t databitlen,
 726     uint8_t *hashval)
 727 {