Ignore:
Timestamp:
Oct 27, 2016 7:58:01 AM (8 years ago)
Author:
ming
Message:

Fixed #1975: Add support to select elliptic curve and signature algorithm for TLS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/ssl_sock.h

    r5238 r5472  
    402402PJ_DECL(pj_ssl_cipher) pj_ssl_cipher_id(const char *cipher_name); 
    403403 
     404/** 
     405 * Elliptic curves enumeration. 
     406 */ 
     407typedef enum pj_ssl_curve 
     408{ 
     409        PJ_TLS_UNKNOWN_CURVE            = 0, 
     410        PJ_TLS_CURVE_SECT163K1          = 1, 
     411        PJ_TLS_CURVE_SECT163R1          = 2, 
     412        PJ_TLS_CURVE_SECT163R2          = 3, 
     413        PJ_TLS_CURVE_SECT193R1          = 4, 
     414        PJ_TLS_CURVE_SECT193R2          = 5, 
     415        PJ_TLS_CURVE_SECT233K1          = 6, 
     416        PJ_TLS_CURVE_SECT233R1          = 7, 
     417        PJ_TLS_CURVE_SECT239K1          = 8, 
     418        PJ_TLS_CURVE_SECT283K1          = 9, 
     419        PJ_TLS_CURVE_SECT283R1          = 10, 
     420        PJ_TLS_CURVE_SECT409K1          = 11, 
     421        PJ_TLS_CURVE_SECT409R1          = 12, 
     422        PJ_TLS_CURVE_SECT571K1          = 13, 
     423        PJ_TLS_CURVE_SECT571R1          = 14, 
     424        PJ_TLS_CURVE_SECP160K1          = 15, 
     425        PJ_TLS_CURVE_SECP160R1          = 16, 
     426        PJ_TLS_CURVE_SECP160R2          = 17, 
     427        PJ_TLS_CURVE_SECP192K1          = 18, 
     428        PJ_TLS_CURVE_SECP192R1          = 19, 
     429        PJ_TLS_CURVE_SECP224K1          = 20, 
     430        PJ_TLS_CURVE_SECP224R1          = 21, 
     431        PJ_TLS_CURVE_SECP256K1          = 22, 
     432        PJ_TLS_CURVE_SECP256R1          = 23, 
     433        PJ_TLS_CURVE_SECP384R1          = 24, 
     434        PJ_TLS_CURVE_SECP521R1          = 25, 
     435        PJ_TLS_CURVE_BRAINPOOLP256R1    = 26, 
     436        PJ_TLS_CURVE_BRAINPOOLP384R1    = 27, 
     437        PJ_TLS_CURVE_BRAINPOOLP512R1    = 28, 
     438        PJ_TLS_CURVE_ARBITRARY_EXPLICIT_PRIME_CURVES    = 0XFF01, 
     439        PJ_TLS_CURVE_ARBITRARY_EXPLICIT_CHAR2_CURVES    = 0XFF02 
     440} pj_ssl_curve; 
     441 
     442/** 
     443 * Get curve list supported by SSL/TLS backend. 
     444 * 
     445 * @param curves        The curves buffer to receive curve list. 
     446 * @param curves_num    Maximum number of curves to be received. 
     447 * 
     448 * @return              PJ_SUCCESS when successful. 
     449 */ 
     450PJ_DECL(pj_status_t) pj_ssl_curve_get_availables(pj_ssl_curve curves[], 
     451                                                 unsigned *curve_num); 
     452 
     453/** 
     454 * Check if the specified curve is supported by SSL/TLS backend. 
     455 * 
     456 * @param curve         The curve. 
     457 * 
     458 * @return              PJ_TRUE when supported. 
     459 */ 
     460PJ_DECL(pj_bool_t) pj_ssl_curve_is_supported(pj_ssl_curve curve); 
     461 
     462 
     463/** 
     464 * Get curve name string. 
     465 * 
     466 * @param curve         The curve. 
     467 * 
     468 * @return              The curve name or NULL if curve is not recognized/ 
     469 *                      supported. 
     470 */ 
     471PJ_DECL(const char*) pj_ssl_curve_name(pj_ssl_curve curve); 
     472 
     473/** 
     474 * Get curve ID from curve name string. Note that on different backends 
     475 * (e.g. OpenSSL or Symbian implementation), curve names may not be 
     476 * equivalent for the same curve ID. 
     477 * 
     478 * @param curve_name    The curve name string. 
     479 * 
     480 * @return              The curve ID or PJ_TLS_UNKNOWN_CURVE if the curve 
     481 *                      name string is not recognized/supported. 
     482 */ 
     483PJ_DECL(pj_ssl_curve) pj_ssl_curve_id(const char *curve_name); 
     484 
     485/* 
     486 * Entropy enumeration 
     487 */ 
     488typedef enum pj_ssl_entropy 
     489{ 
     490        PJ_SSL_ENTROPY_NONE     = 0, 
     491        PJ_SSL_ENTROPY_EGD      = 1, 
     492        PJ_SSL_ENTROPY_RANDOM   = 2, 
     493        PJ_SSL_ENTROPY_URANDOM  = 3, 
     494        PJ_SSL_ENTROPY_FILE     = 4, 
     495        PJ_SSL_ENTROPY_UNKNOWN  = 0x0F 
     496} pj_ssl_entropy_t; 
    404497 
    405498/** 
     
    771864 
    772865    /** 
     866     * Number of curves contained in the specified curve preference. 
     867     * If this is set to zero, then default curve list of the backend 
     868     * will be used. 
     869     * 
     870     * Default: 0 (zero). 
     871     */ 
     872    unsigned curves_num; 
     873 
     874    /** 
     875     * Curves and order preference. The #pj_ssl_curve_get_availables() 
     876     * can be used to check the available curves supported by backend. 
     877     */ 
     878    pj_ssl_curve *curves; 
     879 
     880    /** 
     881     * The supported signature algorithms. Set the sigalgs string 
     882     * using this form: 
     883     * "<DIGEST>+<ALGORITHM>:<DIGEST>+<ALGORITHM>" 
     884     * Digests are: "RSA", "DSA" or "ECDSA" 
     885     * Algorithms are: "MD5", "SHA1", "SHA224", "SHA256", "SHA384", "SHA512" 
     886     * Example: "ECDSA+SHA256:RSA+SHA256" 
     887     */ 
     888    pj_str_t    sigalgs; 
     889 
     890    /** 
     891     * Reseed random number generator. 
     892     * For type #PJ_SSL_ENTROPY_FILE, parameter \a entropy_path 
     893     * must be set to a file. 
     894     * For type #PJ_SSL_ENTROPY_EGD, parameter \a entropy_path 
     895     * must be set to a socket. 
     896     * 
     897     * Default value is PJ_SSL_ENTROPY_NONE. 
     898    */ 
     899    pj_ssl_entropy_t    entropy_type; 
     900 
     901    /** 
     902     * When using a file/socket for entropy #PJ_SSL_ENTROPY_EGD or 
     903     * #PJ_SSL_ENTROPY_FILE, \a entropy_path must contain the path 
     904     * to entropy socket/file. 
     905     * 
     906     * Default value is an empty string. 
     907     */ 
     908    pj_str_t            entropy_path; 
     909 
     910    /** 
    773911     * Security negotiation timeout. If this is set to zero (both sec and  
    774912     * msec), the negotiation doesn't have a timeout. 
Note: See TracChangeset for help on using the changeset viewer.