replace macros with functions
[openssl.git] / ssl / ssl_lib.c
index a8bc044cbe9569878822aecf08c98c088a4907a7..1cc3ac9cb6c4e7d17381c31d943cfb23c4c53572 100644 (file)
@@ -1272,7 +1272,7 @@ char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len)
                c=sk_SSL_CIPHER_value(sk,i);
                for (cp=c->name; *cp; )
                        {
-                       if (len-- == 0)
+                       if (len-- <= 0)
                                {
                                *p='\0';
                                return(buf);
@@ -2550,14 +2550,14 @@ int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
 #endif
 
 void SSL_set_info_callback(SSL *ssl,
-                          void (*cb)(const SSL *ssl,int type,int val))
+       void (*cb)(const SSL *ssl,int type,int val))
        {
        ssl->info_callback=cb;
        }
 
 /* One compiler (Diab DCC) doesn't like argument names in returned
    function pointer.  */
-void (*SSL_get_info_callback(const SSL *ssl))(const SSL * /*ssl*/,int /*type*/,int /*val*/)
+void (*SSL_get_info_callback(const SSL *ssl))(const SSL * /*ssl*/,int /*type*/,int /*val*/) 
        {
        return ssl->info_callback;
        }
@@ -2764,6 +2764,36 @@ const char *SSL_get_psk_identity(const SSL *s)
                return NULL;
        return(s->session->psk_identity);
        }
+
+void SSL_set_psk_client_callback(SSL *s, 
+       unsigned int (*cb)(SSL *ssl, const char *hint,
+                char *identity, unsigned int max_identity_len, unsigned char *psk,
+                unsigned int max_psk_len))
+       {
+       s->psk_client_callback = cb;    
+       }
+
+void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,
+       unsigned int (*cb)(SSL *ssl, const char *hint,
+                char *identity, unsigned int max_identity_len, unsigned char *psk,
+                unsigned int max_psk_len))
+       {
+       ctx->psk_client_callback = cb;  
+       }
+
+void SSL_set_psk_server_callback(SSL *s, 
+       unsigned int (*cb)(SSL *ssl, const char *identity,
+                unsigned char *psk, unsigned int max_psk_len))
+       {
+       s->psk_server_callback = cb;    
+       }
+
+void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx,
+       unsigned int (*cb)(SSL *ssl, const char *identity,
+                unsigned char *psk, unsigned int max_psk_len))
+       {
+       ctx->psk_server_callback = cb;  
+       }
 #endif
 
 void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))