- return gnutls_priority_init( &ctx->prios, suites, &err );
-#else
- char *ptr, *end;
- int i, j, len, num;
- int *list, nkx = 0, ncipher = 0, nmac = 0;
- int *kx, *cipher, *mac;
-
- num = 0;
- ptr = suites;
- do {
- end = strchr(ptr, ':');
- if ( end )
- len = end - ptr;
- else
- len = strlen(ptr);
- for (i=0; i<tlsg_n_ciphers; i++) {
- if ( !strncasecmp( tlsg_ciphers[i].name, ptr, len )) {
- num++;
- break;
- }
- }
- if ( i == tlsg_n_ciphers ) {
- /* unrecognized cipher suite */
- return -1;
- }
- ptr += len + 1;
- } while (end);
-
- /* Space for all 3 lists */
- list = LDAP_MALLOC( (num+1) * sizeof(int) * 3 );
- if ( !list )
- return -1;
- kx = list;
- cipher = kx+num+1;
- mac = cipher+num+1;
-
- ptr = suites;
- do {
- end = strchr(ptr, ':');
- if ( end )
- len = end - ptr;
- else
- len = strlen(ptr);
- for (i=0; i<tlsg_n_ciphers; i++) {
- /* For each cipher suite, insert its algorithms into
- * their respective priority lists. Make sure they
- * only appear once in each list.
- */
- if ( !strncasecmp( tlsg_ciphers[i].name, ptr, len )) {
- for (j=0; j<nkx; j++)
- if ( kx[j] == tlsg_ciphers[i].kx )
- break;
- if ( j == nkx )
- kx[nkx++] = tlsg_ciphers[i].kx;
- for (j=0; j<ncipher; j++)
- if ( cipher[j] == tlsg_ciphers[i].cipher )
- break;
- if ( j == ncipher )
- cipher[ncipher++] = tlsg_ciphers[i].cipher;
- for (j=0; j<nmac; j++)
- if ( mac[j] == tlsg_ciphers[i].mac )
- break;
- if ( j == nmac )
- mac[nmac++] = tlsg_ciphers[i].mac;
- break;
- }
- }
- ptr += len + 1;
- } while (end);
- kx[nkx] = 0;
- cipher[ncipher] = 0;
- mac[nmac] = 0;
- ctx->kx_list = kx;
- ctx->cipher_list = cipher;
- ctx->mac_list = mac;
- return 0;
-#endif