Changeset 5665:10c164fd8e04 in roaraudio for libroar


Ignore:
Timestamp:
09/23/12 11:35:35 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Added support for v3 and v5 UUIDs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/uuid.c

    r5589 r5665  
    8484 return 0; 
    8585} 
    86 int roar_uuid_gen(roar_uuid_t uuid, enum roar_uuid_type type, roar_uuid_t ns, void * argp, ssize_t arglen) { 
     86 
     87int roar_uuid_gen(roar_uuid_t uuid, enum roar_uuid_type type, const roar_uuid_t ns, const void * argp, ssize_t arglen) { 
     88 unsigned char digest[20]; 
     89 
    8790 if ( uuid == NULL ) { 
    8891  roar_err_set(ROAR_ERROR_FAULT); 
     
    101104    return 0; 
    102105   break; 
    103   case ROAR_UUID_TYPE_DCE_SECURITY: 
    104106  case ROAR_UUID_TYPE_MD5: 
    105107  case ROAR_UUID_TYPE_SHA1: 
     108    if ( ns == NULL || argp == NULL ) { 
     109     roar_err_set(ROAR_ERROR_FAULT); 
     110     return -1; 
     111    } 
     112 
     113    if ( arglen < 1 ) { 
     114     roar_err_set(ROAR_ERROR_INVAL); 
     115     return -1; 
     116    } 
     117 
     118    if ( roar_hash_salted_buffer(digest, ns, sizeof(roar_uuid_t), 
     119                                 type == ROAR_UUID_TYPE_MD5 ? ROAR_HT_MD5 : ROAR_HT_SHA1, 
     120                                 argp, arglen) == -1 ) 
     121     return -1; 
     122 
     123    memcpy(uuid, digest, sizeof(roar_uuid_t)); 
     124    uuid[6] = (uuid[8] & 0x0F) | (type << 4); // Version 
     125    uuid[8] = (uuid[8] & 0x3F) | 0x80; // Variant 
     126 
     127    return 0; 
     128   break; 
     129  case ROAR_UUID_TYPE_DCE_SECURITY: 
     130  case ROAR_UUID_TYPE_TIME: 
    106131    roar_err_set(ROAR_ERROR_NOTSUP); 
    107132    return -1; 
Note: See TracChangeset for help on using the changeset viewer.