|
@@ -231,7 +231,7 @@ static void readable_string(unsigned char *orig, unsigned char *out, size_t sz)
|
|
|
out[0]=0;
|
|
|
|
|
|
for(i = 0; i < sz; ++i) {
|
|
|
- sprintf((char*)(out + (i * 2)), "%02x", (unsigned int)orig[i]);
|
|
|
+ snprintf((char*)(out + (i * 2)), 4, "%02x", (unsigned int)orig[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -441,20 +441,20 @@ int stun_is_error_response_str(const u08bits* buf, size_t len, int *err_code, u0
|
|
|
if(err_code) {
|
|
|
stun_attr_ref sar = stun_attr_get_first_by_type_str(buf, len, STUN_ATTRIBUTE_ERROR_CODE);
|
|
|
if(sar) {
|
|
|
- if(stun_attr_get_len(sar)>=4) {
|
|
|
- const u08bits* val = (const u08bits*)stun_attr_get_value(sar);
|
|
|
- *err_code=(int)(val[2]*100 + val[3]);
|
|
|
- if(err_msg && err_msg_size>0) {
|
|
|
- err_msg[0]=0;
|
|
|
- if(stun_attr_get_len(sar)>4) {
|
|
|
- size_t msg_len = stun_attr_get_len(sar) - 4;
|
|
|
- if(msg_len>(err_msg_size-1))
|
|
|
- msg_len=err_msg_size - 1;
|
|
|
- ns_bcopy(val+4, err_msg, msg_len);
|
|
|
- err_msg[msg_len]=0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if(stun_attr_get_len(sar)>=4) {
|
|
|
+ const u08bits* val = (const u08bits*)stun_attr_get_value(sar);
|
|
|
+ *err_code=(int)(val[2]*100 + val[3]);
|
|
|
+ if(err_msg && err_msg_size>0) {
|
|
|
+ err_msg[0]=0;
|
|
|
+ if(stun_attr_get_len(sar)>4) {
|
|
|
+ size_t msg_len = stun_attr_get_len(sar) - 4;
|
|
|
+ if(msg_len>(err_msg_size-1))
|
|
|
+ msg_len=err_msg_size - 1;
|
|
|
+ ns_bcopy(val+4, err_msg, msg_len);
|
|
|
+ err_msg[msg_len]=0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return 1;
|
|
@@ -467,7 +467,7 @@ int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code
|
|
|
{
|
|
|
int ret = stun_is_error_response_str(buf, len, err_code, err_msg, err_msg_size);
|
|
|
|
|
|
- if(ret && (((*err_code) == 401) || ((*err_code) == 438) || ((*err_code) == SHA_TOO_WEAK_ERROR_CODE))) {
|
|
|
+ if(ret && (((*err_code) == 401) || ((*err_code) == 438) )) {
|
|
|
|
|
|
stun_attr_ref sar = stun_attr_get_first_by_type_str(buf,len,STUN_ATTRIBUTE_REALM);
|
|
|
if(sar) {
|
|
@@ -591,39 +591,79 @@ void old_stun_init_success_response_str(u16bits method, u08bits* buf, size_t *le
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const u08bits* get_default_reason(int error_code)
|
|
|
+{
|
|
|
+ const u08bits* reason = (const u08bits *) "Unknown error";
|
|
|
+
|
|
|
+ switch (error_code){
|
|
|
+ case 300:
|
|
|
+ reason = (const u08bits *) "Try Alternate";
|
|
|
+ break;
|
|
|
+ case 400:
|
|
|
+ reason = (const u08bits *) "Bad Request";
|
|
|
+ break;
|
|
|
+ case 401:
|
|
|
+ reason = (const u08bits *) "Unauthorized";
|
|
|
+ break;
|
|
|
+ case 403:
|
|
|
+ reason = (const u08bits *) "Forbidden";
|
|
|
+ break;
|
|
|
+ case 404:
|
|
|
+ reason = (const u08bits *) "Not Found";
|
|
|
+ break;
|
|
|
+ case 420:
|
|
|
+ reason = (const u08bits *) "Unknown Attribute";
|
|
|
+ break;
|
|
|
+ case 437:
|
|
|
+ reason = (const u08bits *) "Allocation Mismatch";
|
|
|
+ break;
|
|
|
+ case 438:
|
|
|
+ reason = (const u08bits *) "Stale Nonce";
|
|
|
+ break;
|
|
|
+ case 440:
|
|
|
+ reason = (const u08bits *) "Address Family not Supported";
|
|
|
+ break;
|
|
|
+ case 441:
|
|
|
+ reason = (const u08bits *) "Wrong Credentials";
|
|
|
+ break;
|
|
|
+ case 442:
|
|
|
+ reason = (const u08bits *) "Unsupported Transport Protocol";
|
|
|
+ break;
|
|
|
+ case 443:
|
|
|
+ reason = (const u08bits *) "Peer Address Family Mismatch";
|
|
|
+ break;
|
|
|
+ case 446:
|
|
|
+ reason = (const u08bits *) "Connection Already Exists";
|
|
|
+ break;
|
|
|
+ case 447:
|
|
|
+ reason = (const u08bits *) "Connection Timeout or Failure";
|
|
|
+ break;
|
|
|
+ case 486:
|
|
|
+ reason = (const u08bits *) "Allocation Quota Reached";
|
|
|
+ break;
|
|
|
+ case 487:
|
|
|
+ reason = (const u08bits *) "Role Conflict";
|
|
|
+ break;
|
|
|
+ case 500:
|
|
|
+ reason = (const u08bits *) "Server Error";
|
|
|
+ break;
|
|
|
+ case 508:
|
|
|
+ reason = (const u08bits *) "Insufficient Capacity";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ ;
|
|
|
+ };
|
|
|
+
|
|
|
+ return reason;
|
|
|
+}
|
|
|
+
|
|
|
static void stun_init_error_response_common_str(u08bits* buf, size_t *len,
|
|
|
u16bits error_code, const u08bits *reason,
|
|
|
stun_tid* id)
|
|
|
{
|
|
|
|
|
|
- if (!reason) {
|
|
|
-
|
|
|
- switch (error_code){
|
|
|
- case 300:
|
|
|
- reason = (const u08bits *) "Try Alternate";
|
|
|
- break;
|
|
|
- case 400:
|
|
|
- reason = (const u08bits *) "Bad Request";
|
|
|
- break;
|
|
|
- case 401:
|
|
|
- reason = (const u08bits *) "Unauthorized";
|
|
|
- break;
|
|
|
- case 404:
|
|
|
- reason = (const u08bits *) "Not Found";
|
|
|
- break;
|
|
|
- case 420:
|
|
|
- reason = (const u08bits *) "Unknown Attribute";
|
|
|
- break;
|
|
|
- case 438:
|
|
|
- reason = (const u08bits *) "Stale Nonce";
|
|
|
- break;
|
|
|
- case 500:
|
|
|
- reason = (const u08bits *) "Server Error";
|
|
|
- break;
|
|
|
- default:
|
|
|
- reason = (const u08bits *) "Unknown Error";
|
|
|
- break;
|
|
|
- };
|
|
|
+ if (!reason || !strcmp((const char*)reason,"Unknown error")) {
|
|
|
+ reason = get_default_reason(error_code);
|
|
|
}
|
|
|
|
|
|
u08bits avalue[513];
|
|
@@ -1426,17 +1466,33 @@ int stun_attr_add_bandwidth_str(u08bits* buf, size_t *len, band_limit_t bps0) {
|
|
|
return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_NEW_BANDWIDTH,(u08bits*)(&field),sizeof(field));
|
|
|
}
|
|
|
|
|
|
-int stun_attr_add_address_error_code(u08bits* buf, size_t *len, int requested_address_family, u08bits error_code)
|
|
|
+int stun_attr_add_address_error_code(u08bits* buf, size_t *len, int requested_address_family, int error_code)
|
|
|
{
|
|
|
- u08bits field[4];
|
|
|
- field[0]=(u08bits)requested_address_family;
|
|
|
- field[1]=error_code;
|
|
|
- field[2]=0;
|
|
|
- field[3]=0;
|
|
|
- return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_ADDRESS_ERROR_CODE,field,sizeof(field));
|
|
|
+ const u08bits *reason = get_default_reason(error_code);
|
|
|
+
|
|
|
+ u08bits avalue[513];
|
|
|
+ avalue[0] = (u08bits)requested_address_family;
|
|
|
+ avalue[1] = 0;
|
|
|
+ avalue[2] = (u08bits) (error_code / 100);
|
|
|
+ avalue[3] = (u08bits) (error_code % 100);
|
|
|
+ strncpy((s08bits*) (avalue + 4), (const s08bits*) reason, sizeof(avalue)-4);
|
|
|
+ avalue[sizeof(avalue)-1]=0;
|
|
|
+ int alen = 4 + strlen((const s08bits*) (avalue+4));
|
|
|
+
|
|
|
+ //"Manual" padding for compatibility with classic old stun:
|
|
|
+ {
|
|
|
+ int rem = alen % 4;
|
|
|
+ if(rem) {
|
|
|
+ alen +=(4-rem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ADDRESS_ERROR_CODE, (u08bits*) avalue, alen);
|
|
|
+
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
-int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_address_family, u08bits *error_code)
|
|
|
+int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_address_family, int *error_code)
|
|
|
{
|
|
|
if(requested_address_family) {
|
|
|
*requested_address_family = 0;
|
|
@@ -1459,7 +1515,7 @@ int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_ad
|
|
|
*requested_address_family = value[0];
|
|
|
}
|
|
|
if(error_code) {
|
|
|
- *error_code = value[1];
|
|
|
+ *error_code = (int)(value[2]*100+value[3]);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
@@ -1745,7 +1801,7 @@ void print_hmac(const char *name, const void *s, size_t len)
|
|
|
/*
|
|
|
* Return -1 if failure, 0 if the integrity is not correct, 1 if OK
|
|
|
*/
|
|
|
-int stun_check_message_integrity_by_key_str(turn_credential_type ct, u08bits *buf, size_t len, hmackey_t key, password_t pwd, SHATYPE shatype, int *too_weak)
|
|
|
+int stun_check_message_integrity_by_key_str(turn_credential_type ct, u08bits *buf, size_t len, hmackey_t key, password_t pwd, SHATYPE shatype)
|
|
|
{
|
|
|
int res = 0;
|
|
|
u08bits new_hmac[MAXSHASIZE];
|
|
@@ -1761,41 +1817,21 @@ int stun_check_message_integrity_by_key_str(turn_credential_type ct, u08bits *bu
|
|
|
switch(sarlen) {
|
|
|
case SHA256SIZEBYTES:
|
|
|
shasize = SHA256SIZEBYTES;
|
|
|
- if(shatype > SHATYPE_SHA256) {
|
|
|
- if(too_weak)
|
|
|
- *too_weak = 1;
|
|
|
- return -1;
|
|
|
- }
|
|
|
if(shatype != SHATYPE_SHA256)
|
|
|
return -1;
|
|
|
break;
|
|
|
case SHA384SIZEBYTES:
|
|
|
shasize = SHA384SIZEBYTES;
|
|
|
- if(shatype > SHATYPE_SHA384) {
|
|
|
- if(too_weak)
|
|
|
- *too_weak = 1;
|
|
|
- return -1;
|
|
|
- }
|
|
|
if(shatype != SHATYPE_SHA384)
|
|
|
return -1;
|
|
|
break;
|
|
|
case SHA512SIZEBYTES:
|
|
|
shasize = SHA512SIZEBYTES;
|
|
|
- if(shatype > SHATYPE_SHA512) {
|
|
|
- if(too_weak)
|
|
|
- *too_weak = 1;
|
|
|
- return -1;
|
|
|
- }
|
|
|
if(shatype != SHATYPE_SHA512)
|
|
|
return -1;
|
|
|
break;
|
|
|
case SHA1SIZEBYTES:
|
|
|
shasize = SHA1SIZEBYTES;
|
|
|
- if(shatype > SHATYPE_SHA1) {
|
|
|
- if(too_weak)
|
|
|
- *too_weak = 1;
|
|
|
- return -1;
|
|
|
- }
|
|
|
if(shatype != SHATYPE_SHA1)
|
|
|
return -1;
|
|
|
break;
|
|
@@ -1847,7 +1883,7 @@ int stun_check_message_integrity_str(turn_credential_type ct, u08bits *buf, size
|
|
|
else if (stun_produce_integrity_key_str(uname, realm, upwd, key, shatype) < 0)
|
|
|
return -1;
|
|
|
|
|
|
- return stun_check_message_integrity_by_key_str(ct, buf, len, key, pwd, shatype, NULL);
|
|
|
+ return stun_check_message_integrity_by_key_str(ct, buf, len, key, pwd, shatype);
|
|
|
}
|
|
|
|
|
|
/* RFC 5780 */
|
|
@@ -1963,12 +1999,14 @@ static void normalize_algorithm(char *s)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static size_t calculate_enc_key_length(ENC_ALG a)
|
|
|
+size_t calculate_enc_key_length(ENC_ALG a);
|
|
|
+size_t calculate_enc_key_length(ENC_ALG a)
|
|
|
{
|
|
|
switch(a) {
|
|
|
- case AES_128_CBC:
|
|
|
- case AEAD_AES_128_GCM:
|
|
|
+#if !defined(TURN_NO_GCM)
|
|
|
+ case A128GCM:
|
|
|
return 16;
|
|
|
+#endif
|
|
|
default:
|
|
|
break;
|
|
|
};
|
|
@@ -1976,105 +2014,30 @@ static size_t calculate_enc_key_length(ENC_ALG a)
|
|
|
return 32;
|
|
|
}
|
|
|
|
|
|
-static size_t calculate_auth_key_length(AUTH_ALG a)
|
|
|
+size_t calculate_auth_key_length(ENC_ALG a);
|
|
|
+size_t calculate_auth_key_length(ENC_ALG a)
|
|
|
{
|
|
|
switch(a) {
|
|
|
- case AUTH_ALG_HMAC_SHA_1:
|
|
|
- return 20;
|
|
|
- case AUTH_ALG_HMAC_SHA_256_128:
|
|
|
- return 32;
|
|
|
- case AUTH_ALG_HMAC_SHA_256:
|
|
|
- return 32;
|
|
|
- case AUTH_ALG_HMAC_SHA_384:
|
|
|
- return 48;
|
|
|
- case AUTH_ALG_HMAC_SHA_512:
|
|
|
- return 64;
|
|
|
+#if !defined(TURN_NO_GCM)
|
|
|
+ case A256GCM:
|
|
|
+ case A128GCM:
|
|
|
+ return 0;
|
|
|
+#endif
|
|
|
default:
|
|
|
break;
|
|
|
};
|
|
|
|
|
|
- return 32;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
-static size_t calculate_auth_output_length(AUTH_ALG a)
|
|
|
+int calculate_key(char *key, size_t key_size,
|
|
|
+ char *new_key, size_t new_key_size);
|
|
|
+int calculate_key(char *key, size_t key_size,
|
|
|
+ char *new_key, size_t new_key_size)
|
|
|
{
|
|
|
- switch(a) {
|
|
|
- case AUTH_ALG_HMAC_SHA_1:
|
|
|
- return 20;
|
|
|
- case AUTH_ALG_HMAC_SHA_256_128:
|
|
|
- return 16;
|
|
|
- case AUTH_ALG_HMAC_SHA_256:
|
|
|
- return 32;
|
|
|
- case AUTH_ALG_HMAC_SHA_384:
|
|
|
- return 48;
|
|
|
- case AUTH_ALG_HMAC_SHA_512:
|
|
|
- return 64;
|
|
|
- default:
|
|
|
- break;
|
|
|
- };
|
|
|
-
|
|
|
- return 32;
|
|
|
-}
|
|
|
+ UNUSED_ARG(key_size);
|
|
|
|
|
|
-static int calculate_key(char *key, size_t key_size,
|
|
|
- char *new_key, size_t new_key_size,
|
|
|
- SHATYPE shatype,
|
|
|
- char *err_msg, size_t err_msg_size,
|
|
|
- const char *info)
|
|
|
-{
|
|
|
- //Extract:
|
|
|
- u08bits prk[128];
|
|
|
- unsigned int prk_len = 0;
|
|
|
- stun_calculate_hmac((const u08bits *)key, key_size, (const u08bits *)"", 0, prk, &prk_len, shatype);
|
|
|
-
|
|
|
- //Expand:
|
|
|
- size_t info_len = strlen(info);
|
|
|
- u08bits buf[256];
|
|
|
- ns_bcopy(info,buf,info_len);
|
|
|
- buf[info_len]=0x01;
|
|
|
- u08bits hmac1[128];
|
|
|
- unsigned int hmac1_len = 0;
|
|
|
- stun_calculate_hmac((const u08bits *)buf, info_len+1, prk, prk_len, hmac1, &hmac1_len, shatype);
|
|
|
- ns_bcopy(hmac1,new_key,hmac1_len);
|
|
|
-
|
|
|
- //Check
|
|
|
- if(new_key_size>hmac1_len) {
|
|
|
- ns_bcopy(hmac1,buf,hmac1_len);
|
|
|
- ns_bcopy(info,buf+hmac1_len,info_len);
|
|
|
- buf[hmac1_len+info_len]=0x02;
|
|
|
- u08bits hmac2[128];
|
|
|
- unsigned int hmac2_len = 0;
|
|
|
- stun_calculate_hmac((const u08bits *)buf, hmac1_len+info_len+1, prk, prk_len, hmac2, &hmac2_len, shatype);
|
|
|
- ns_bcopy(hmac2,new_key+hmac1_len,hmac2_len);
|
|
|
- if(new_key_size > (hmac1_len + hmac2_len)) {
|
|
|
-
|
|
|
- ns_bcopy(hmac2,buf,hmac2_len);
|
|
|
- ns_bcopy(info,buf+hmac2_len,info_len);
|
|
|
- buf[hmac2_len+info_len]=0x03;
|
|
|
- u08bits hmac3[128];
|
|
|
- unsigned int hmac3_len = 0;
|
|
|
- stun_calculate_hmac((const u08bits *)buf, hmac2_len+info_len+1, prk, prk_len, hmac3, &hmac3_len, shatype);
|
|
|
- ns_bcopy(hmac3,new_key+hmac1_len+hmac2_len,hmac3_len);
|
|
|
- if(new_key_size > (hmac1_len + hmac2_len + hmac3_len)) {
|
|
|
-
|
|
|
- ns_bcopy(hmac3,buf,hmac3_len);
|
|
|
- ns_bcopy(info,buf+hmac3_len,info_len);
|
|
|
- buf[hmac3_len+info_len]=0x04;
|
|
|
- u08bits hmac4[128];
|
|
|
- unsigned int hmac4_len = 0;
|
|
|
- stun_calculate_hmac((const u08bits *)buf, hmac3_len+info_len+1, prk, prk_len, hmac4, &hmac4_len, shatype);
|
|
|
- ns_bcopy(hmac4,new_key+hmac1_len+hmac2_len+hmac3_len,hmac4_len);
|
|
|
- if(new_key_size > (hmac1_len + hmac2_len + hmac3_len + hmac4_len)) {
|
|
|
-
|
|
|
- if(err_msg) {
|
|
|
- snprintf(err_msg,err_msg_size,"Wrong HKDF procedure (key sizes): output.sz=%lu, hmac(1)=%lu, hmac(2)=%lu",(unsigned long)new_key_size,(unsigned long)hmac1_len,(unsigned long)hmac2_len);
|
|
|
- }
|
|
|
- OAUTH_ERROR("Wrong HKDF procedure (key sizes): output.sz=%lu, hmac(1)=%lu, hmac(2)=%lu",(unsigned long)new_key_size,(unsigned long)hmac1_len,(unsigned long)hmac2_len);
|
|
|
- return -1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ ns_bcopy(key,new_key,new_key_size);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -2088,27 +2051,16 @@ int convert_oauth_key_data(const oauth_key_data *oakd0, oauth_key *key, char *er
|
|
|
oauth_key_data *oakd = &oakd_obj;
|
|
|
|
|
|
if(!(oakd->ikm_key_size)) {
|
|
|
- if(!(oakd->as_rs_key_size)) {
|
|
|
- if(err_msg) {
|
|
|
- snprintf(err_msg,err_msg_size,"AS-RS key is not defined");
|
|
|
- }
|
|
|
- OAUTH_ERROR("AS-RS key is not defined\n");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- if(!(oakd->auth_key_size)) {
|
|
|
- //AEAD ?
|
|
|
+ if(err_msg) {
|
|
|
+ snprintf(err_msg,err_msg_size,"key is not defined");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
remove_spaces(oakd->kid);
|
|
|
|
|
|
- remove_spaces(oakd->hkdf_hash_func);
|
|
|
remove_spaces(oakd->as_rs_alg);
|
|
|
- remove_spaces(oakd->auth_alg);
|
|
|
|
|
|
- normalize_algorithm(oakd->hkdf_hash_func);
|
|
|
normalize_algorithm(oakd->as_rs_alg);
|
|
|
- normalize_algorithm(oakd->auth_alg);
|
|
|
|
|
|
if(!(oakd->kid[0])) {
|
|
|
if(err_msg) {
|
|
@@ -2122,10 +2074,6 @@ int convert_oauth_key_data(const oauth_key_data *oakd0, oauth_key *key, char *er
|
|
|
|
|
|
STRCPY(key->kid,oakd->kid);
|
|
|
|
|
|
- ns_bcopy(oakd->as_rs_key,key->as_rs_key,sizeof(key->as_rs_key));
|
|
|
- key->as_rs_key_size = oakd->as_rs_key_size;
|
|
|
- ns_bcopy(oakd->auth_key,key->auth_key,sizeof(key->auth_key));
|
|
|
- key->auth_key_size = oakd->auth_key_size;
|
|
|
ns_bcopy(oakd->ikm_key,key->ikm_key,sizeof(key->ikm_key));
|
|
|
key->ikm_key_size = oakd->ikm_key_size;
|
|
|
|
|
@@ -2135,57 +2083,20 @@ int convert_oauth_key_data(const oauth_key_data *oakd0, oauth_key *key, char *er
|
|
|
if(!(key->timestamp)) key->timestamp = OAUTH_DEFAULT_TIMESTAMP;
|
|
|
if(!(key->lifetime)) key->lifetime = OAUTH_DEFAULT_LIFETIME;
|
|
|
|
|
|
- key->hkdf_hash_func = SHATYPE_SHA256;
|
|
|
- if(!strcmp(oakd->hkdf_hash_func,"SHA1") || !strcmp(oakd->hkdf_hash_func,"SHA-1")) {
|
|
|
- key->hkdf_hash_func = SHATYPE_SHA1;
|
|
|
- } else if(!strcmp(oakd->hkdf_hash_func,"SHA256") || !strcmp(oakd->hkdf_hash_func,"SHA-256")) {
|
|
|
- key->hkdf_hash_func = SHATYPE_SHA256;
|
|
|
- } else if(!strcmp(oakd->hkdf_hash_func,"SHA384") || !strcmp(oakd->hkdf_hash_func,"SHA-384")) {
|
|
|
- key->hkdf_hash_func = SHATYPE_SHA384;
|
|
|
- } else if(!strcmp(oakd->hkdf_hash_func,"SHA512") || !strcmp(oakd->hkdf_hash_func,"SHA-512")) {
|
|
|
- key->hkdf_hash_func = SHATYPE_SHA512;
|
|
|
- } else if(oakd->hkdf_hash_func[0]) {
|
|
|
- if(err_msg) {
|
|
|
- snprintf(err_msg,err_msg_size,"Wrong HKDF hash function algorithm: %s",oakd->hkdf_hash_func);
|
|
|
- }
|
|
|
- OAUTH_ERROR("Wrong HKDF hash function algorithm: %s\n",oakd->hkdf_hash_func);
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- key->auth_alg = AUTH_ALG_DEFAULT;
|
|
|
- if(!strcmp(oakd->auth_alg,"HMAC-SHA-1") || !strcmp(oakd->auth_alg,"HMAC-SHA1")) {
|
|
|
- key->auth_alg = AUTH_ALG_HMAC_SHA_1;
|
|
|
- } else if(!strcmp(oakd->auth_alg,"HMAC-SHA-256")) {
|
|
|
- key->auth_alg = AUTH_ALG_HMAC_SHA_256;
|
|
|
- } else if(!strcmp(oakd->auth_alg,"HMAC-SHA-384")) {
|
|
|
- key->auth_alg = AUTH_ALG_HMAC_SHA_384;
|
|
|
- } else if(!strcmp(oakd->auth_alg,"HMAC-SHA-512")) {
|
|
|
- key->auth_alg = AUTH_ALG_HMAC_SHA_512;
|
|
|
- } else if(!strcmp(oakd->auth_alg,"HMAC-SHA-256-128")) {
|
|
|
- key->auth_alg = AUTH_ALG_HMAC_SHA_256_128;
|
|
|
- } else if(oakd->auth_alg[0]) {
|
|
|
- if(err_msg) {
|
|
|
- snprintf(err_msg,err_msg_size,"Wrong oAuth token hash algorithm: %s (1)\n",oakd->auth_alg);
|
|
|
- }
|
|
|
- key->auth_alg = AUTH_ALG_ERROR;
|
|
|
- OAUTH_ERROR("Wrong oAuth token hash algorithm: %s (2)\n",oakd->auth_alg);
|
|
|
- return -1;
|
|
|
- } else {
|
|
|
- key->auth_alg = AUTH_ALG_UNDEFINED;
|
|
|
- }
|
|
|
-
|
|
|
+ key->as_rs_alg = ENC_ALG_ERROR;
|
|
|
+#if !defined(TURN_NO_GCM)
|
|
|
key->as_rs_alg = ENC_ALG_DEFAULT;
|
|
|
- if(!strcmp(oakd->as_rs_alg,"AES-128-CBC")) {
|
|
|
- key->as_rs_alg = AES_128_CBC;
|
|
|
- } else if(!strcmp(oakd->as_rs_alg,"AES-256-CBC")) {
|
|
|
- key->as_rs_alg = AES_256_CBC;
|
|
|
- } else if(!strcmp(oakd->as_rs_alg,"AEAD-AES-128-GCM")) {
|
|
|
- key->as_rs_alg = AEAD_AES_128_GCM;
|
|
|
- key->auth_alg = AUTH_ALG_UNDEFINED;
|
|
|
- } else if(!strcmp(oakd->as_rs_alg,"AEAD-AES-256-GCM")) {
|
|
|
- key->as_rs_alg = AEAD_AES_256_GCM;
|
|
|
- key->auth_alg = AUTH_ALG_UNDEFINED;
|
|
|
- } else if(oakd->as_rs_alg[0]) {
|
|
|
+ if(!strcmp(oakd->as_rs_alg,"A128GCM")) {
|
|
|
+ key->as_rs_alg = A128GCM;
|
|
|
+ key->auth_key_size = 0;
|
|
|
+ key->auth_key[0] = 0;
|
|
|
+ } else if(!strcmp(oakd->as_rs_alg,"A256GCM")) {
|
|
|
+ key->as_rs_alg = A256GCM;
|
|
|
+ key->auth_key_size = 0;
|
|
|
+ key->auth_key[0] = 0;
|
|
|
+ } else
|
|
|
+#endif
|
|
|
+ {
|
|
|
if(err_msg) {
|
|
|
snprintf(err_msg,err_msg_size,"Wrong oAuth token encryption algorithm: %s (2)\n",oakd->as_rs_alg);
|
|
|
}
|
|
@@ -2193,39 +2104,33 @@ int convert_oauth_key_data(const oauth_key_data *oakd0, oauth_key *key, char *er
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- if(key->auth_alg == AUTH_ALG_UNDEFINED) {
|
|
|
- //AEAD
|
|
|
- key->auth_key_size = 0;
|
|
|
- key->auth_key[0] = 0;
|
|
|
- } else if(!(key->auth_key_size)) {
|
|
|
- key->auth_key_size = calculate_auth_key_length(key->auth_alg);
|
|
|
- if(calculate_key(key->ikm_key,key->ikm_key_size,key->auth_key,key->auth_key_size,key->hkdf_hash_func,err_msg,err_msg_size,"AUTH key")<0) {
|
|
|
+#if !defined(TURN_NO_GCM)
|
|
|
+
|
|
|
+ key->auth_key_size = calculate_auth_key_length(key->as_rs_alg);
|
|
|
+ if(key->auth_key_size) {
|
|
|
+ if(calculate_key(key->ikm_key,key->ikm_key_size,key->auth_key,key->auth_key_size)<0) {
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(!(key->as_rs_key_size)) {
|
|
|
- key->as_rs_key_size = calculate_enc_key_length(key->as_rs_alg);
|
|
|
- if(calculate_key(key->ikm_key,key->ikm_key_size,key->as_rs_key,key->as_rs_key_size,key->hkdf_hash_func,err_msg,err_msg_size,"AS-RS key")<0) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ key->as_rs_key_size = calculate_enc_key_length(key->as_rs_alg);
|
|
|
+ if(calculate_key(key->ikm_key,key->ikm_key_size,key->as_rs_key,key->as_rs_key_size)<0) {
|
|
|
+ return -1;
|
|
|
}
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static const EVP_CIPHER *get_cipher_type(ENC_ALG enc_alg)
|
|
|
+const EVP_CIPHER *get_cipher_type(ENC_ALG enc_alg);
|
|
|
+const EVP_CIPHER *get_cipher_type(ENC_ALG enc_alg)
|
|
|
{
|
|
|
switch(enc_alg) {
|
|
|
- case AES_256_CBC:
|
|
|
- return EVP_aes_256_cbc();
|
|
|
- case AES_128_CBC:
|
|
|
- return EVP_aes_128_cbc();
|
|
|
#if !defined(TURN_NO_GCM)
|
|
|
- case AEAD_AES_128_GCM:
|
|
|
+ case A128GCM:
|
|
|
return EVP_aes_128_gcm();
|
|
|
- case AEAD_AES_256_GCM:
|
|
|
+ case A256GCM:
|
|
|
return EVP_aes_256_gcm();
|
|
|
#endif
|
|
|
default:
|
|
@@ -2235,45 +2140,9 @@ static const EVP_CIPHER *get_cipher_type(ENC_ALG enc_alg)
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
-static const EVP_MD *get_auth_type(AUTH_ALG aa)
|
|
|
-{
|
|
|
- switch(aa) {
|
|
|
- case AUTH_ALG_HMAC_SHA_1:
|
|
|
- return EVP_sha1();
|
|
|
-#if !defined(OPENSSL_NO_SHA256) && defined(SHA256_DIGEST_LENGTH)
|
|
|
- case AUTH_ALG_HMAC_SHA_256_128:
|
|
|
- case AUTH_ALG_HMAC_SHA_256:
|
|
|
- return EVP_sha256();
|
|
|
-#endif
|
|
|
-#if !defined(OPENSSL_NO_SHA384) && defined(SHA384_DIGEST_LENGTH)
|
|
|
- case AUTH_ALG_HMAC_SHA_384:
|
|
|
- return EVP_sha384();
|
|
|
-#endif
|
|
|
-#if !defined(OPENSSL_NO_SHA512) && defined(SHA512_DIGEST_LENGTH)
|
|
|
- case AUTH_ALG_HMAC_SHA_512:
|
|
|
- return EVP_sha512();
|
|
|
-#endif
|
|
|
- default:
|
|
|
- break;
|
|
|
- };
|
|
|
- OAUTH_ERROR("%s: Unknown auth algorithm: %d\n",__FUNCTION__,(int)aa);
|
|
|
- return NULL;
|
|
|
-}
|
|
|
-
|
|
|
-static void update_hmac_len(AUTH_ALG aa, unsigned int *hmac_len)
|
|
|
-{
|
|
|
- if(hmac_len) {
|
|
|
- switch(aa) {
|
|
|
- case AUTH_ALG_HMAC_SHA_256_128:
|
|
|
- *hmac_len = 16;
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- };
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static int my_EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|
|
+int my_EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|
|
+ int *outl, const unsigned char *in, int inl);
|
|
|
+int my_EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|
|
int *outl, const unsigned char *in, int inl)
|
|
|
{
|
|
|
int cycle = 0;
|
|
@@ -2292,7 +2161,9 @@ static int my_EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-static int my_EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|
|
+int my_EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|
|
+ int *outl, const unsigned char *in, int inl);
|
|
|
+int my_EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|
|
int *outl, const unsigned char *in, int inl)
|
|
|
{
|
|
|
int cycle = 0;
|
|
@@ -2321,8 +2192,15 @@ void print_field(const char* name, const unsigned char* f, size_t len) {
|
|
|
printf("\n<<==field %s\n",name);
|
|
|
}
|
|
|
|
|
|
-static int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken)
|
|
|
+int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken);
|
|
|
+int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken)
|
|
|
{
|
|
|
+ UNUSED_ARG(server_name);
|
|
|
+ UNUSED_ARG(etoken);
|
|
|
+ UNUSED_ARG(key);
|
|
|
+ UNUSED_ARG(dtoken);
|
|
|
+
|
|
|
+ /*
|
|
|
if(server_name && etoken && key && dtoken && (dtoken->enc_block.key_length<=128)) {
|
|
|
|
|
|
unsigned char orig_field[MAX_ENCODED_OAUTH_TOKEN_SIZE];
|
|
@@ -2384,11 +2262,19 @@ static int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_t
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
+ */
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
-static int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken)
|
|
|
+int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken);
|
|
|
+int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken)
|
|
|
{
|
|
|
+ UNUSED_ARG(server_name);
|
|
|
+ UNUSED_ARG(etoken);
|
|
|
+ UNUSED_ARG(key);
|
|
|
+ UNUSED_ARG(dtoken);
|
|
|
+
|
|
|
+ /*
|
|
|
if(server_name && etoken && key && dtoken) {
|
|
|
|
|
|
size_t mac_size = calculate_auth_output_length(key->auth_alg);
|
|
@@ -2462,6 +2348,7 @@ static int decode_oauth_token_normal(const u08bits *server_name, const encoded_o
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
+ */
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -2476,14 +2363,27 @@ static void generate_random_nonce(unsigned char *nonce, size_t sz) {
|
|
|
|
|
|
#if !defined(TURN_NO_GCM)
|
|
|
|
|
|
-static int encode_oauth_token_aead(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const u08bits* nonce0)
|
|
|
-{
|
|
|
- if(server_name && etoken && key && dtoken && (dtoken->enc_block.key_length<128)) {
|
|
|
+static int encode_oauth_token_gcm(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const u08bits* nonce0) {
|
|
|
+ if(server_name && etoken && key && dtoken && (dtoken->enc_block.key_length<=MAXSHASIZE)) {
|
|
|
|
|
|
unsigned char orig_field[MAX_ENCODED_OAUTH_TOKEN_SIZE];
|
|
|
ns_bzero(orig_field,sizeof(orig_field));
|
|
|
|
|
|
+ unsigned char nonce[OAUTH_GCM_NONCE_SIZE];
|
|
|
+ if(nonce0) {
|
|
|
+ ns_bcopy(nonce0,nonce,sizeof(nonce));
|
|
|
+ } else {
|
|
|
+ generate_random_nonce(nonce, sizeof(nonce));
|
|
|
+ }
|
|
|
+
|
|
|
size_t len = 0;
|
|
|
+
|
|
|
+ *((uint16_t*)(orig_field+len)) = nswap16(OAUTH_GCM_NONCE_SIZE);
|
|
|
+ len +=2;
|
|
|
+
|
|
|
+ ns_bcopy(nonce,orig_field+len,OAUTH_GCM_NONCE_SIZE);
|
|
|
+ len += OAUTH_GCM_NONCE_SIZE;
|
|
|
+
|
|
|
*((uint16_t*)(orig_field+len)) = nswap16(dtoken->enc_block.key_length);
|
|
|
len +=2;
|
|
|
|
|
@@ -2500,15 +2400,6 @@ static int encode_oauth_token_aead(const u08bits *server_name, encoded_oauth_tok
|
|
|
if(!cipher)
|
|
|
return -1;
|
|
|
|
|
|
- unsigned char *encoded_field = (unsigned char*)etoken->token;
|
|
|
-
|
|
|
- unsigned char nonce[OAUTH_AEAD_NONCE_SIZE];
|
|
|
- if(nonce0) {
|
|
|
- ns_bcopy(nonce0,nonce,sizeof(nonce));
|
|
|
- } else {
|
|
|
- generate_random_nonce(nonce, sizeof(nonce));
|
|
|
- }
|
|
|
-
|
|
|
EVP_CIPHER_CTX ctx;
|
|
|
EVP_CIPHER_CTX_init(&ctx);
|
|
|
|
|
@@ -2519,7 +2410,7 @@ static int encode_oauth_token_aead(const u08bits *server_name, encoded_oauth_tok
|
|
|
EVP_CIPHER_CTX_set_padding(&ctx,1);
|
|
|
|
|
|
/* Set IV length if default 12 bytes (96 bits) is not appropriate */
|
|
|
- if(1 != EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, OAUTH_AEAD_NONCE_SIZE, NULL))
|
|
|
+ if(1 != EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, OAUTH_GCM_NONCE_SIZE, NULL))
|
|
|
return -1;
|
|
|
|
|
|
/* Initialize key and IV */
|
|
@@ -2536,21 +2427,23 @@ static int encode_oauth_token_aead(const u08bits *server_name, encoded_oauth_tok
|
|
|
return -1;
|
|
|
|
|
|
outl=0;
|
|
|
+ unsigned char *encoded_field = (unsigned char*)etoken->token;
|
|
|
+ ns_bcopy(orig_field,encoded_field,OAUTH_GCM_NONCE_SIZE + 2);
|
|
|
+ encoded_field += OAUTH_GCM_NONCE_SIZE + 2;
|
|
|
+ unsigned char *start_field = orig_field + OAUTH_GCM_NONCE_SIZE + 2;
|
|
|
+ len -= OAUTH_GCM_NONCE_SIZE + 2;
|
|
|
|
|
|
- if(1 != my_EVP_EncryptUpdate(&ctx, encoded_field, &outl, orig_field, (int)len))
|
|
|
+ if(1 != my_EVP_EncryptUpdate(&ctx, encoded_field, &outl, start_field, (int)len))
|
|
|
return -1;
|
|
|
|
|
|
int tmp_outl = 0;
|
|
|
EVP_EncryptFinal_ex(&ctx, encoded_field + outl, &tmp_outl);
|
|
|
outl += tmp_outl;
|
|
|
|
|
|
- EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_GET_TAG, OAUTH_AEAD_TAG_SIZE, encoded_field + outl);
|
|
|
- outl += OAUTH_AEAD_TAG_SIZE;
|
|
|
+ EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_GET_TAG, OAUTH_GCM_TAG_SIZE, encoded_field + outl);
|
|
|
+ outl += OAUTH_GCM_TAG_SIZE;
|
|
|
|
|
|
- ns_bcopy(nonce, encoded_field + outl, OAUTH_AEAD_NONCE_SIZE);
|
|
|
- outl += OAUTH_AEAD_NONCE_SIZE; //encoded+tag+hmac
|
|
|
-
|
|
|
- etoken->size = outl;
|
|
|
+ etoken->size = 2 + OAUTH_GCM_NONCE_SIZE + outl;
|
|
|
|
|
|
EVP_CIPHER_CTX_cleanup(&ctx);
|
|
|
|
|
@@ -2559,22 +2452,28 @@ static int encode_oauth_token_aead(const u08bits *server_name, encoded_oauth_tok
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
-static int decode_oauth_token_aead(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken)
|
|
|
+static int decode_oauth_token_gcm(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken)
|
|
|
{
|
|
|
if(server_name && etoken && key && dtoken) {
|
|
|
|
|
|
- size_t min_encoded_field_size = 2+4+8+OAUTH_AEAD_NONCE_SIZE+OAUTH_AEAD_TAG_SIZE+1;
|
|
|
+ unsigned char snl[2];
|
|
|
+ ns_bcopy((const unsigned char*)(etoken->token),snl,2);
|
|
|
+ const unsigned char *csnl = snl;
|
|
|
+
|
|
|
+ uint16_t nonce_len = nswap16(*((const uint16_t*)csnl));
|
|
|
+
|
|
|
+ size_t min_encoded_field_size = 2+4+8+nonce_len+2+OAUTH_GCM_TAG_SIZE+1;
|
|
|
if(etoken->size < min_encoded_field_size) {
|
|
|
OAUTH_ERROR("%s: token size too small: %d\n",__FUNCTION__,(int)etoken->size);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- const unsigned char* encoded_field = (const unsigned char*)etoken->token;
|
|
|
- unsigned int encoded_field_size = (unsigned int)etoken->size-OAUTH_AEAD_NONCE_SIZE - OAUTH_AEAD_TAG_SIZE;
|
|
|
- const unsigned char* nonce = ((const unsigned char*)etoken->token) + encoded_field_size + OAUTH_AEAD_TAG_SIZE;
|
|
|
+ const unsigned char* encoded_field = (const unsigned char*)(etoken->token + nonce_len + 2);
|
|
|
+ unsigned int encoded_field_size = (unsigned int)etoken->size - nonce_len - 2 - OAUTH_GCM_TAG_SIZE;
|
|
|
+ const unsigned char* nonce = ((const unsigned char*)etoken->token + 2);
|
|
|
|
|
|
- unsigned char tag[OAUTH_AEAD_TAG_SIZE];
|
|
|
- ns_bcopy(((const unsigned char*)etoken->token) + encoded_field_size, tag ,sizeof(tag));
|
|
|
+ unsigned char tag[OAUTH_GCM_TAG_SIZE];
|
|
|
+ ns_bcopy(((const unsigned char*)etoken->token) + nonce_len + 2 + encoded_field_size, tag ,sizeof(tag));
|
|
|
|
|
|
unsigned char decoded_field[MAX_ENCODED_OAUTH_TOKEN_SIZE];
|
|
|
|
|
@@ -2595,7 +2494,7 @@ static int decode_oauth_token_aead(const u08bits *server_name, const encoded_oau
|
|
|
//EVP_CIPHER_CTX_set_padding(&ctx,1);
|
|
|
|
|
|
/* Set IV length if default 12 bytes (96 bits) is not appropriate */
|
|
|
- if(1 != EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, OAUTH_AEAD_NONCE_SIZE, NULL)) {
|
|
|
+ if(1 != EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, nonce_len, NULL)) {
|
|
|
OAUTH_ERROR("%s: Cannot set nonce length\n",__FUNCTION__);
|
|
|
return -1;
|
|
|
}
|
|
@@ -2608,7 +2507,7 @@ static int decode_oauth_token_aead(const u08bits *server_name, const encoded_oau
|
|
|
|
|
|
/* Set expected tag value. A restriction in OpenSSL 1.0.1c and earlier
|
|
|
+ * required the tag before any AAD or ciphertext */
|
|
|
- EVP_CIPHER_CTX_ctrl (&ctx, EVP_CTRL_GCM_SET_TAG, OAUTH_AEAD_TAG_SIZE, tag);
|
|
|
+ EVP_CIPHER_CTX_ctrl (&ctx, EVP_CTRL_GCM_SET_TAG, OAUTH_GCM_TAG_SIZE, tag);
|
|
|
|
|
|
int outl=0;
|
|
|
size_t sn_len = strlen((const char*)server_name);
|
|
@@ -2661,13 +2560,10 @@ int encode_oauth_token(const u08bits *server_name, encoded_oauth_token *etoken,
|
|
|
UNUSED_ARG(nonce);
|
|
|
if(server_name && etoken && key && dtoken) {
|
|
|
switch(key->as_rs_alg) {
|
|
|
- case AES_256_CBC:
|
|
|
- case AES_128_CBC:
|
|
|
- return encode_oauth_token_normal(server_name, etoken,key,dtoken);
|
|
|
#if !defined(TURN_NO_GCM)
|
|
|
- case AEAD_AES_128_GCM:
|
|
|
- case AEAD_AES_256_GCM:
|
|
|
- return encode_oauth_token_aead(server_name, etoken,key,dtoken,nonce);
|
|
|
+ case A256GCM:
|
|
|
+ case A128GCM:
|
|
|
+ return encode_oauth_token_gcm(server_name, etoken,key,dtoken,nonce);
|
|
|
#endif
|
|
|
default:
|
|
|
fprintf(stderr,"Unsupported AS_RS algorithm: %d\n",(int)key->as_rs_alg);
|
|
@@ -2681,13 +2577,10 @@ int decode_oauth_token(const u08bits *server_name, const encoded_oauth_token *et
|
|
|
{
|
|
|
if(server_name && etoken && key && dtoken) {
|
|
|
switch(key->as_rs_alg) {
|
|
|
- case AES_256_CBC:
|
|
|
- case AES_128_CBC:
|
|
|
- return decode_oauth_token_normal(server_name, etoken,key,dtoken);
|
|
|
#if !defined(TURN_NO_GCM)
|
|
|
- case AEAD_AES_128_GCM:
|
|
|
- case AEAD_AES_256_GCM:
|
|
|
- return decode_oauth_token_aead(server_name, etoken,key,dtoken);
|
|
|
+ case A256GCM:
|
|
|
+ case A128GCM:
|
|
|
+ return decode_oauth_token_gcm(server_name, etoken,key,dtoken);
|
|
|
#endif
|
|
|
default:
|
|
|
fprintf(stderr,"Unsupported AS_RS algorithm: %d\n",(int)key->as_rs_alg);
|