OpenCores
URL https://opencores.org/ocsvn/bluespec_md6/bluespec_md6/trunk

Subversion Repositories bluespec_md6

[/] [bluespec_md6/] [trunk/] [C_implementation/] [md6_nist.c] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kfleming
/* File:    md6_nist.c
2
** Author:  Ronald L. Rivest
3
** Address: Room 32G-692 Stata Center
4
**          32 Vassar Street
5
**          Cambridge, MA 02139
6
** Email:   rivest@mit.edu
7
** Date:    9/25/2008
8
**
9
** (The following license is known as "The MIT License")
10
**
11
** Copyright (c) 2008 Ronald L. Rivest
12
**
13
** Permission is hereby granted, free of charge, to any person obtaining a copy
14
** of this software and associated documentation files (the "Software"), to deal
15
** in the Software without restriction, including without limitation the rights
16
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
** copies of the Software, and to permit persons to whom the Software is
18
** furnished to do so, subject to the following conditions:
19
**
20
** The above copyright notice and this permission notice shall be included in
21
** all copies or substantial portions of the Software.
22
**
23
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
** THE SOFTWARE.
30
**
31
** (end of license)
32
**
33
** This is part of the definition of the MD6 hash function.
34
** The files defining the MD6 hash function are:
35
**    md6.h
36
**    md6_compress.c
37
**    md6_mode.c
38
**
39
** The files defining the interface between MD6 and the NIST SHA-3
40
** API are:
41
**    md6_nist.h
42
**    md6_nist.c
43
** The NIST SHA-3 API is defined in:
44
**    http://www.csrc.nist.gov/groups/ST/hash/documents/SHA3-C-API.pdf
45
**
46
** See  http://groups.csail.mit.edu/cis/md6  for more information.
47
*/
48
 
49
#include <stdio.h>
50
#include "md6.h"
51
#include "md6_nist.h"
52
 
53
HashReturn Init( hashState *state,
54
                 int hashbitlen
55
                 )
56
{ int err;
57
  if ((err = md6_init( (md6_state *) state,
58
                       hashbitlen
59
                       )))
60
    return err;
61
  state->hashbitlen = hashbitlen;
62
  return SUCCESS;
63
}
64
 
65
HashReturn Update( hashState *state,
66
                   const BitSequence *data,
67
                   DataLength databitlen
68
                   )
69
{ return md6_update( (md6_state *) state,
70
                     (unsigned char *)data,
71
                     (uint64_t) databitlen );
72
}
73
 
74
HashReturn Final( hashState *state,
75
                  BitSequence *hashval
76
                  )
77
{ return md6_final( (md6_state *) state,
78
                    (unsigned char *) hashval
79
                    );
80
}
81
 
82
HashReturn Hash( int hashbitlen,
83
                 const BitSequence *data,
84
                 DataLength databitlen,
85
                 BitSequence *hashval
86
                 )
87
{ int err;
88
  md6_state state;
89
  if ((err = Init( &state, hashbitlen )))
90
    return err;
91
  if ((err = Update( &state, data, databitlen )))
92
    return err;
93
  return Final( &state, hashval );
94
}
95
 
96
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.