ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/hkdf.C
(Generate patch)

Comparing gvpe/src/hkdf.C (file contents):
Revision 1.5 by root, Thu Jun 30 11:43:38 2016 UTC vs.
Revision 1.6 by root, Thu Jun 30 16:31:00 2016 UTC

39 39
40#include "crypto.h" 40#include "crypto.h"
41#include "util.h" 41#include "util.h"
42#include "hkdf.h" 42#include "hkdf.h"
43 43
44hkdf::hkdf (const void *salt, int len, const EVP_MD *xtr_hash)
45: salt (salt), salt_len (len)
46{
47 ctx.init (salt, salt_len, xtr_hash);
48}
49
44void 50void
45hkdf::extract (const void *ikm, int len) 51hkdf::extract (const void *ikm, int len)
46{ 52{
47 ctx.add (ikm, len); 53 ctx.add (ikm, len);
48} 54}
49 55
50void 56void
51hkdf::extract_done (const EVP_MD *prf_hash) 57hkdf::extract_done (const EVP_MD *prf_hash)
52{ 58{
53 ctx.digest (prk); 59 ctx.digest (prk);
54 ctx.init (0, 0, prf_hash); 60 ctx.init (salt, salt_len, prf_hash);
55} 61}
56 62
57void 63void
58hkdf::expand (void *okm, int len, const void *info, int infolen) 64hkdf::expand (void *okm, int len, const void *info, int infolen)
59{ 65{
99 u8 s[256]; 105 u8 s[256];
100 106
101 unhex (const char *hs) 107 unhex (const char *hs)
102 { 108 {
103 l = 0; 109 l = 0;
104 p = 0; 110 p = s;
105 111
106 if (!hs) 112 if (!hs)
107 return; 113 return;
108
109 p = s;
110 114
111 while (*hs) 115 while (*hs)
112 { 116 {
113 int d1 = *hs >= '0' && *hs <= '9' ? *hs - '0' : *hs - 'a' + 10; ++hs; 117 int d1 = *hs >= '0' && *hs <= '9' ? *hs - '0' : *hs - 'a' + 10; ++hs;
114 int d2 = *hs >= '0' && *hs <= '9' ? *hs - '0' : *hs - 'a' + 10; ++hs; 118 int d2 = *hs >= '0' && *hs <= '9' ? *hs - '0' : *hs - 'a' + 10; ++hs;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines