… | |
… | |
34 | #include "conf.h" |
34 | #include "conf.h" |
35 | #include "slog.h" |
35 | #include "slog.h" |
36 | #include "device.h" |
36 | #include "device.h" |
37 | #include "vpn.h" |
37 | #include "vpn.h" |
38 | #include "connection.h" |
38 | #include "connection.h" |
|
|
39 | |
|
|
40 | #include "netcompat.h" |
39 | |
41 | |
40 | #if !HAVE_RAND_PSEUDO_BYTES |
42 | #if !HAVE_RAND_PSEUDO_BYTES |
41 | # define RAND_pseudo_bytes RAND_bytes |
43 | # define RAND_pseudo_bytes RAND_bytes |
42 | #endif |
44 | #endif |
43 | |
45 | |
… | |
… | |
910 | rsachallenge k; |
912 | rsachallenge k; |
911 | |
913 | |
912 | if (0 > RSA_private_decrypt (sizeof (p->encr), |
914 | if (0 > RSA_private_decrypt (sizeof (p->encr), |
913 | (unsigned char *)&p->encr, (unsigned char *)&k, |
915 | (unsigned char *)&p->encr, (unsigned char *)&k, |
914 | ::conf.rsa_key, RSA_PKCS1_OAEP_PADDING)) |
916 | ::conf.rsa_key, RSA_PKCS1_OAEP_PADDING)) |
915 | slog (L_ERR, _("%s(%s): challenge illegal or corrupted"), |
917 | slog (L_ERR, _("%s(%s): challenge illegal or corrupted (%s). mismatched key or config file?"), |
916 | conf->nodename, (const char *)rsi); |
918 | conf->nodename, (const char *)rsi, ERR_error_string (ERR_get_error (), 0)); |
917 | else |
919 | else |
918 | { |
920 | { |
919 | delete octx; |
921 | delete octx; |
920 | |
922 | |
921 | octx = new crypto_ctx (k, 1); |
923 | octx = new crypto_ctx (k, 1); |
… | |
… | |
954 | |
956 | |
955 | rsachallenge chg; |
957 | rsachallenge chg; |
956 | |
958 | |
957 | if (!rsa_cache.find (p->id, chg)) |
959 | if (!rsa_cache.find (p->id, chg)) |
958 | { |
960 | { |
959 | slog (L_ERR, _("%s(%s): unrequested auth response"), |
961 | slog (L_ERR, _("%s(%s): unrequested auth response ignored"), |
960 | conf->nodename, (const char *)rsi); |
962 | conf->nodename, (const char *)rsi); |
961 | break; |
963 | break; |
962 | } |
964 | } |
963 | else |
965 | else |
964 | { |
966 | { |
965 | crypto_ctx *cctx = new crypto_ctx (chg, 0); |
967 | crypto_ctx *cctx = new crypto_ctx (chg, 0); |
966 | |
968 | |
967 | if (!p->hmac_chk (cctx)) |
969 | if (!p->hmac_chk (cctx)) |
|
|
970 | { |
968 | slog (L_ERR, _("%s(%s): hmac authentication error on auth response, received invalid packet\n" |
971 | slog (L_ERR, _("%s(%s): hmac authentication error on auth response, received invalid packet\n" |
969 | "could be an attack, or just corruption or an synchronization error"), |
972 | "could be an attack, or just corruption or an synchronization error"), |
970 | conf->nodename, (const char *)rsi); |
973 | conf->nodename, (const char *)rsi); |
|
|
974 | break; |
|
|
975 | } |
971 | else |
976 | else |
972 | { |
977 | { |
973 | rsaresponse h; |
978 | rsaresponse h; |
974 | |
979 | |
975 | rsa_hash (p->id, chg, h); |
980 | rsa_hash (p->id, chg, h); |