1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
--- connecttoserver.c.orig 2013-02-07 10:42:46 UTC
+++ connecttoserver.c
@@ -517,6 +517,7 @@ int connectviapassword()
#ifdef WITH_SSL
RSA *hisrsa ;
int lenrsa ;
+ BIGNUM *n, *e;
#endif
/*
** Get the socket
@@ -629,33 +630,35 @@ int connectviapassword()
/*
** Getting BIGNUM structures to store the key and exponent
*/
- if ( (hisrsa->n = BN_new()) == NULL) {
+ n = BN_new();
+ e = BN_new();
+ if (n == NULL || e == NULL) {
free(readbuffer) ;
close(tmpctrlsock) ;
printmessage(stderr,CASE_ERROR,56,timestamp,"Error reading encrypted message : %s (%s)\n","getting BIGNUM",(char *) ERR_error_string(ERR_get_error(),NULL)) ;
return -1 ;
}
- if ( (hisrsa->e = BN_new()) == NULL) {
- free(readbuffer) ;
- close(tmpctrlsock) ;
- printmessage(stderr,CASE_ERROR,56,timestamp,"Error reading encrypted message : %s (%s)\n","getting BIGNUM",(char *) ERR_error_string(ERR_get_error(),NULL)) ;
- return -1 ;
- }
/*
** Copy the key and exponent received
*/
- if ( BN_mpi2bn(pubkey,lenkey,hisrsa->n) == NULL ) {
+ if ( BN_mpi2bn(pubkey,lenkey,n) == NULL ) {
free(readbuffer) ;
close(tmpctrlsock) ;
printmessage(stderr,CASE_ERROR,56,timestamp,"Error reading encrypted message : %s (%s)\n","copying pubkey",(char *) ERR_error_string(ERR_get_error(),NULL)) ;
return -1 ;
}
- if ( BN_mpi2bn(pubexponent,lenexpo,hisrsa->e) == NULL ) {
+ if ( BN_mpi2bn(pubexponent,lenexpo,e) == NULL ) {
free(readbuffer) ;
close(tmpctrlsock) ;
printmessage(stderr,CASE_ERROR,56,timestamp,"Error reading encrypted message : %s (%s)\n","copying pubexponent",(char *) ERR_error_string(ERR_get_error(),NULL)) ;
return -1 ;
}
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ hisrsa->n = n;
+ hisrsa->e = e;
+#else
+ RSA_set0_key(hisrsa, n, e, NULL);
+#endif
lenrsa = RSA_size(hisrsa) ;
if (strlen(username) > lenrsa - 41 ) {
|