Skip to content

Commit d5aafe1

Browse files
author
Edward Thomson
committed
hash: drop all declarations from hmac
The builtin hash uses the code verbatim from rfc6234, including prototypes for functions that we don't use (like hmac). Remove all unused prototypes to avoid collisions with things that an operating system might provide (like hmac).
1 parent a677440 commit d5aafe1

File tree

1 file changed

+0
-114
lines changed
  • src/util/hash/rfc6234

1 file changed

+0
-114
lines changed

src/util/hash/rfc6234/sha.h

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -191,49 +191,6 @@ typedef struct SHA256Context SHA224Context;
191191
*/
192192
typedef struct SHA512Context SHA384Context;
193193

194-
/*
195-
* This structure holds context information for all SHA
196-
* hashing operations.
197-
*/
198-
typedef struct USHAContext {
199-
int whichSha; /* which SHA is being used */
200-
union {
201-
SHA1Context sha1Context;
202-
SHA224Context sha224Context; SHA256Context sha256Context;
203-
SHA384Context sha384Context; SHA512Context sha512Context;
204-
} ctx;
205-
} USHAContext;
206-
207-
/*
208-
* This structure will hold context information for the HMAC
209-
* keyed-hashing operation.
210-
*/
211-
typedef struct HMACContext {
212-
int whichSha; /* which SHA is being used */
213-
int hashSize; /* hash size of SHA being used */
214-
int blockSize; /* block size of SHA being used */
215-
USHAContext shaContext; /* SHA context */
216-
unsigned char k_opad[USHA_Max_Message_Block_Size];
217-
/* outer padding - key XORd with opad */
218-
int Computed; /* Is the MAC computed? */
219-
int Corrupted; /* Cumulative corruption code */
220-
221-
} HMACContext;
222-
223-
/*
224-
* This structure will hold context information for the HKDF
225-
* extract-and-expand Key Derivation Functions.
226-
*/
227-
typedef struct HKDFContext {
228-
int whichSha; /* which SHA is being used */
229-
HMACContext hmacContext;
230-
int hashSize; /* hash size of SHA being used */
231-
unsigned char prk[USHAMaxHashSize];
232-
/* pseudo-random key - output of hkdfInput */
233-
int Computed; /* Is the key material computed? */
234-
int Corrupted; /* Cumulative corruption code */
235-
} HKDFContext;
236-
237194
/*
238195
* Function Prototypes
239196
*/
@@ -283,75 +240,4 @@ extern int SHA512FinalBits(SHA512Context *, uint8_t bits,
283240
extern int SHA512Result(SHA512Context *,
284241
uint8_t Message_Digest[SHA512HashSize]);
285242

286-
/* Unified SHA functions, chosen by whichSha */
287-
extern int USHAReset(USHAContext *context, SHAversion whichSha);
288-
extern int USHAInput(USHAContext *context,
289-
const uint8_t *bytes, unsigned int bytecount);
290-
extern int USHAFinalBits(USHAContext *context,
291-
uint8_t bits, unsigned int bit_count);
292-
extern int USHAResult(USHAContext *context,
293-
uint8_t Message_Digest[USHAMaxHashSize]);
294-
extern int USHABlockSize(enum SHAversion whichSha);
295-
extern int USHAHashSize(enum SHAversion whichSha);
296-
extern int USHAHashSizeBits(enum SHAversion whichSha);
297-
extern const char *USHAHashName(enum SHAversion whichSha);
298-
299-
#if 0
300-
/*
301-
* HMAC Keyed-Hashing for Message Authentication, RFC 2104,
302-
* for all SHAs.
303-
* This interface allows a fixed-length text input to be used.
304-
*/
305-
extern int hmac(SHAversion whichSha, /* which SHA algorithm to use */
306-
const unsigned char *text, /* pointer to data stream */
307-
int text_len, /* length of data stream */
308-
const unsigned char *key, /* pointer to authentication key */
309-
int key_len, /* length of authentication key */
310-
uint8_t digest[USHAMaxHashSize]); /* caller digest to fill in */
311-
#endif
312-
313-
/*
314-
* HMAC Keyed-Hashing for Message Authentication, RFC 2104,
315-
* for all SHAs.
316-
* This interface allows any length of text input to be used.
317-
*/
318-
extern int hmacReset(HMACContext *context, enum SHAversion whichSha,
319-
const unsigned char *key, int key_len);
320-
extern int hmacInput(HMACContext *context, const unsigned char *text,
321-
int text_len);
322-
extern int hmacFinalBits(HMACContext *context, uint8_t bits,
323-
unsigned int bit_count);
324-
extern int hmacResult(HMACContext *context,
325-
uint8_t digest[USHAMaxHashSize]);
326-
327-
/*
328-
* HKDF HMAC-based Extract-and-Expand Key Derivation Function,
329-
* RFC 5869, for all SHAs.
330-
*/
331-
extern int hkdf(SHAversion whichSha, const unsigned char *salt,
332-
int salt_len, const unsigned char *ikm, int ikm_len,
333-
const unsigned char *info, int info_len,
334-
uint8_t okm[ ], int okm_len);
335-
extern int hkdfExtract(SHAversion whichSha, const unsigned char *salt,
336-
int salt_len, const unsigned char *ikm,
337-
int ikm_len, uint8_t prk[USHAMaxHashSize]);
338-
extern int hkdfExpand(SHAversion whichSha, const uint8_t prk[ ],
339-
int prk_len, const unsigned char *info,
340-
int info_len, uint8_t okm[ ], int okm_len);
341-
342-
/*
343-
* HKDF HMAC-based Extract-and-Expand Key Derivation Function,
344-
* RFC 5869, for all SHAs.
345-
* This interface allows any length of text input to be used.
346-
*/
347-
extern int hkdfReset(HKDFContext *context, enum SHAversion whichSha,
348-
const unsigned char *salt, int salt_len);
349-
extern int hkdfInput(HKDFContext *context, const unsigned char *ikm,
350-
int ikm_len);
351-
extern int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits,
352-
unsigned int ikm_bit_count);
353-
extern int hkdfResult(HKDFContext *context,
354-
uint8_t prk[USHAMaxHashSize],
355-
const unsigned char *info, int info_len,
356-
uint8_t okm[USHAMaxHashSize], int okm_len);
357243
#endif /* _SHA_H_ */

0 commit comments

Comments
 (0)