@@ -5125,7 +5125,7 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
5125
5125
ast_channel_hangupcause_set (c , AST_CAUSE_BEARERCAPABILITY_NOTAVAIL );
5126
5126
return -1 ;
5127
5127
}
5128
- if (((cai .authmethods & IAX_AUTH_MD5 ) || (cai .authmethods & IAX_AUTH_PLAINTEXT )) &&
5128
+ if (((cai .authmethods & IAX_AUTH_RSA ) || ( cai . authmethods & IAX_AUTH_MD5 ) || (cai .authmethods & IAX_AUTH_PLAINTEXT )) &&
5129
5129
ast_strlen_zero (cai .secret ) && ast_strlen_zero (pds .password )) {
5130
5130
ast_log (LOG_WARNING , "Call terminated. Encryption forced but no secret provided\n" );
5131
5131
return -1 ;
@@ -8385,6 +8385,18 @@ static int authenticate(const char *challenge, const char *secret, const char *k
8385
8385
res = 0 ;
8386
8386
}
8387
8387
}
8388
+
8389
+ if (pvt && !ast_strlen_zero (secret )) {
8390
+ struct MD5Context md5 ;
8391
+ unsigned char digest [16 ];
8392
+
8393
+ MD5Init (& md5 );
8394
+ MD5Update (& md5 , (unsigned char * ) challenge , strlen (challenge ));
8395
+ MD5Update (& md5 , (unsigned char * ) secret , strlen (secret ));
8396
+ MD5Final (digest , & md5 );
8397
+
8398
+ build_encryption_keys (digest , pvt );
8399
+ }
8388
8400
}
8389
8401
}
8390
8402
/* Fall back */
@@ -8496,7 +8508,7 @@ static int authenticate_reply(struct chan_iax2_pvt *p, struct ast_sockaddr *addr
8496
8508
8497
8509
if (ies -> encmethods ) {
8498
8510
if (ast_strlen_zero (p -> secret ) &&
8499
- ((ies -> authmethods & IAX_AUTH_MD5 ) || (ies -> authmethods & IAX_AUTH_PLAINTEXT ))) {
8511
+ ((ies -> authmethods & IAX_AUTH_RSA ) || ( ies -> authmethods & IAX_AUTH_MD5 ) || (ies -> authmethods & IAX_AUTH_PLAINTEXT ))) {
8500
8512
ast_log (LOG_WARNING , "Call terminated. Encryption requested by peer but no secret available locally\n" );
8501
8513
return -1 ;
8502
8514
}
@@ -10959,8 +10971,8 @@ static int socket_process_helper(struct iax2_thread *thread)
10959
10971
}
10960
10972
break ;
10961
10973
}
10962
- if (iaxs [fr -> callno ]-> authmethods & IAX_AUTH_MD5 )
10963
- merge_encryption (iaxs [fr -> callno ],ies .encmethods );
10974
+ if (iaxs [fr -> callno ]-> authmethods & ( IAX_AUTH_MD5 | IAX_AUTH_RSA ) )
10975
+ merge_encryption (iaxs [fr -> callno ], ies .encmethods );
10964
10976
else
10965
10977
iaxs [fr -> callno ]-> encmethods = 0 ;
10966
10978
if (!authenticate_request (fr -> callno ) && iaxs [fr -> callno ])
0 commit comments