krb5: Reorder checks in _key_schedule
_krb5_find_enctype is a moderately expensive operation, as it does a linear search of the enctype lists. Avoid calling it in _key_schedule when we already have a key schedule in place. This change makes the most common check the first in the function.
This commit is contained in:
		
				
					committed by
					
						
						Jeffrey Altman
					
				
			
			
				
	
			
			
			
						parent
						
							aedc1fd4bd
						
					
				
				
					commit
					152a23f2ce
				
			@@ -132,9 +132,14 @@ _key_schedule(krb5_context context,
 | 
			
		||||
	      struct _krb5_key_data *key)
 | 
			
		||||
{
 | 
			
		||||
    krb5_error_code ret;
 | 
			
		||||
    struct _krb5_encryption_type *et = _krb5_find_enctype(key->key->keytype);
 | 
			
		||||
    struct _krb5_encryption_type *et;
 | 
			
		||||
    struct _krb5_key_type *kt;
 | 
			
		||||
 | 
			
		||||
    if (key->schedule != NULL)
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
    et = _krb5_find_enctype(key->key->keytype);
 | 
			
		||||
 | 
			
		||||
    if (et == NULL) {
 | 
			
		||||
        return unsupported_enctype (context,
 | 
			
		||||
                               key->key->keytype);
 | 
			
		||||
@@ -144,8 +149,6 @@ _key_schedule(krb5_context context,
 | 
			
		||||
 | 
			
		||||
    if(kt->schedule == NULL)
 | 
			
		||||
	return 0;
 | 
			
		||||
    if (key->schedule != NULL)
 | 
			
		||||
	return 0;
 | 
			
		||||
    ALLOC(key->schedule, 1);
 | 
			
		||||
    if (key->schedule == NULL)
 | 
			
		||||
	return krb5_enomem(context);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user