Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 672204
Collapse All | Expand All

(-)a/cyacas/yacas-kernel/include/hmac_sha256.hpp.ORIG (-1 / +1 lines)
Lines 40-46 Link Here
40
    std::string hexdigest();
40
    std::string hexdigest();
41
41
42
private:
42
private:
43
    HMAC_CTX _ctx;
43
    HMAC_CTX *_ctxp;
44
};
44
};
45
45
46
#endif
46
#endif
(-)a/cyacas/yacas-kernel/src/hmac_sha256.cpp.ORIG (-7 / +6 lines)
Lines 32-40 Link Here
32
}
32
}
33
33
34
HMAC_SHA256::HMAC_SHA256(const std::string& key)
34
HMAC_SHA256::HMAC_SHA256(const std::string& key)
35
{
35
{   _ctxp= HMAC_CTX_new();
36
    HMAC_CTX_init(&_ctx);
36
    HMAC_Init_ex(_ctxp, key.c_str(), key.size(), EVP_sha256(), nullptr);
37
    HMAC_Init_ex(&_ctx, key.c_str(), key.size(), EVP_sha256(), nullptr);
38
}
37
}
39
38
40
HMAC_SHA256::HMAC_SHA256(const std::string& key, const std::string& msg):
39
HMAC_SHA256::HMAC_SHA256(const std::string& key, const std::string& msg):
Lines 45-62 Link Here
45
45
46
HMAC_SHA256::HMAC_SHA256(const HMAC_SHA256& other)
46
HMAC_SHA256::HMAC_SHA256(const HMAC_SHA256& other)
47
{
47
{
48
    HMAC_CTX_copy(&_ctx, const_cast<HMAC_CTX*>(&other._ctx));
48
    HMAC_CTX_copy(_ctxp, const_cast<HMAC_CTX*>(other._ctxp));
49
}
49
}
50
50
51
HMAC_SHA256::~HMAC_SHA256()
51
HMAC_SHA256::~HMAC_SHA256()
52
{
52
{
53
    HMAC_CTX_cleanup(&_ctx);
53
    HMAC_CTX_free(_ctxp);
54
}
54
}
55
55
56
56
57
void HMAC_SHA256::update(const std::string& msg)
57
void HMAC_SHA256::update(const std::string& msg)
58
{
58
{
59
    HMAC_Update(&_ctx, (const unsigned char*)(msg.c_str()), msg.size());
59
    HMAC_Update(_ctxp, (const unsigned char*)(msg.c_str()), msg.size());
60
}
60
}
61
61
62
std::string HMAC_SHA256::hexdigest()
62
std::string HMAC_SHA256::hexdigest()
Lines 65-71 Link Here
65
    
65
    
66
    unsigned char result[n];
66
    unsigned char result[n];
67
    unsigned result_len = n;
67
    unsigned result_len = n;
68
    HMAC_Final(&_ctx, result, &result_len);
68
    HMAC_Final(_ctxp, result, &result_len);
69
69
70
    std::string s(2 * n, 0);
70
    std::string s(2 * n, 0);
71
    for (unsigned i = 0; i < n; ++i) {
71
    for (unsigned i = 0; i < n; ++i) {

Return to bug 672204