Add.
[gnutls.git] / lib / gnutlsxx.cpp
blobb350c050abcfc60b9473cbfb78915483322f9511
1 #include <gnutls/gnutlsxx.h>
3 using namespace gnutls;
5 inline int RETWRAP_NET(int ret)
7 if (gnutls_error_is_fatal(ret)) throw(exception(ret));
8 else return ret;
11 inline int RETWRAP(int ret)
13 if (ret < 0) throw(exception(ret));
14 return ret;
17 session::session( gnutls_connection_end_t end)
19 RETWRAP(gnutls_init( &this->s, end));
22 session::session( session& s)
24 this->s = s.s;
27 session::~session()
29 gnutls_deinit( this->s);
32 int session::bye( gnutls_close_request_t how)
34 return RETWRAP_NET( gnutls_bye( this->s, how));
37 int session::handshake ()
39 return RETWRAP_NET( gnutls_handshake( this->s));
43 server_session::server_session() : session( GNUTLS_SERVER)
47 int server_session::rehandshake()
49 return RETWRAP_NET( gnutls_rehandshake( this->s));
52 gnutls_alert_description_t session::get_alert() const
54 return gnutls_alert_get( this->s);
57 int session::send_alert ( gnutls_alert_level_t level,
58 gnutls_alert_description_t desc)
60 return RETWRAP_NET(gnutls_alert_send( this->s, level, desc));
63 int session::send_appropriate_alert (int err)
65 return RETWRAP_NET(gnutls_alert_send_appropriate( this->s, err));
68 gnutls_cipher_algorithm_t session::get_cipher() const
70 return gnutls_cipher_get( this->s);
73 gnutls_kx_algorithm_t session::get_kx () const
75 return gnutls_kx_get( this->s);
78 gnutls_mac_algorithm_t session::get_mac () const
80 return gnutls_mac_get( this->s);
83 gnutls_compression_method_t session::get_compression() const
85 return gnutls_compression_get( this->s);
88 gnutls_certificate_type_t session::get_certificate_type() const
90 return gnutls_certificate_type_get( this->s);
93 void session::set_private_extensions ( bool allow)
95 gnutls_handshake_set_private_extensions( this->s, (int)allow);
98 gnutls_handshake_description_t session::get_handshake_last_out() const
100 return gnutls_handshake_get_last_out( this->s);
103 gnutls_handshake_description_t session::get_handshake_last_in() const
105 return gnutls_handshake_get_last_in( this->s);
108 ssize_t session::send (const void *data, size_t sizeofdata)
110 return RETWRAP_NET(gnutls_record_send( this->s, data, sizeofdata));
113 ssize_t session::recv (void *data, size_t sizeofdata)
115 return RETWRAP_NET(gnutls_record_recv( this->s, data, sizeofdata));
118 bool session::get_record_direction() const
120 return gnutls_record_get_direction(this->s);
123 // maximum packet size
124 size_t session::get_max_size () const
126 return gnutls_record_get_max_size( this->s);
129 void session::set_max_size(size_t size)
131 RETWRAP( gnutls_record_set_max_size( this->s, size));
134 size_t session::check_pending () const
136 return gnutls_record_check_pending( this->s);
140 void session::prf (size_t label_size, const char *label,
141 int server_random_first,
142 size_t extra_size, const char *extra,
143 size_t outsize, char *out)
145 RETWRAP(gnutls_prf( this->s, label_size, label, server_random_first,
146 extra_size, extra, outsize, out));
149 void session::prf_raw ( size_t label_size, const char *label,
150 size_t seed_size, const char *seed,
151 size_t outsize, char *out)
153 RETWRAP( gnutls_prf_raw( this->s, label_size, label, seed_size, seed, outsize, out));
157 void session::set_cipher_priority (const int *list)
159 RETWRAP( gnutls_cipher_set_priority( this->s, list));
162 void session::set_mac_priority (const int *list)
164 RETWRAP( gnutls_mac_set_priority( this->s, list));
167 void session::set_compression_priority (const int *list)
169 RETWRAP( gnutls_compression_set_priority( this->s, list));
172 void session::set_kx_priority (const int *list)
174 RETWRAP( gnutls_kx_set_priority( this->s, list));
177 void session::set_protocol_priority (const int *list)
179 RETWRAP( gnutls_protocol_set_priority( this->s, list));
182 void session::set_certificate_type_priority (const int *list)
184 RETWRAP( gnutls_certificate_type_set_priority( this->s, list));
188 /* if you just want some defaults, use the following.
190 void session::set_default_priority(priority_flag flag)
192 if (flag == EXPORT_CIPHERS)
193 RETWRAP( gnutls_set_default_export_priority( this->s));
194 else
195 RETWRAP( gnutls_set_default_priority( this->s));
198 gnutls_protocol_t session::get_protocol_version() const
200 return gnutls_protocol_get_version( this->s);
203 void session::set_data ( const void *session_data,
204 size_t session_data_size)
206 RETWRAP(gnutls_session_set_data( this->s, session_data, session_data_size));
209 void session::get_data (void *session_data,
210 size_t * session_data_size) const
212 RETWRAP(gnutls_session_get_data( this->s, session_data, session_data_size));
215 void session::get_data(gnutls_session_t session,
216 gnutls_datum_t & data) const
218 RETWRAP(gnutls_session_get_data2( this->s, &data));
222 void session::get_id ( void *session_id,
223 size_t * session_id_size) const
225 RETWRAP( gnutls_session_get_id( this->s, session_id, session_id_size));
228 bool session::is_resumed() const
230 int ret = gnutls_session_is_resumed( this->s);
232 if (ret != 0) return true;
233 return false;
237 bool session::get_peers_certificate(std::vector<gnutls_datum_t> &out_certs) const
239 const gnutls_datum_t *certs;
240 unsigned int certs_size;
242 certs = gnutls_certificate_get_peers (this->s, &certs_size);
244 if (certs==NULL) return false;
246 for(unsigned int i=0;i<certs_size;i++)
247 out_certs.push_back( certs[i]);
249 return true;
252 bool session::get_peers_certificate(const gnutls_datum_t** certs, unsigned int *certs_size) const
254 *certs = gnutls_certificate_get_peers (this->s, certs_size);
256 if (*certs==NULL) return false;
257 return true;
260 void session::get_our_certificate(gnutls_datum& cert) const
262 const gnutls_datum_t *d;
264 d = gnutls_certificate_get_ours(this->s);
265 if (d==NULL)
266 throw(exception( GNUTLS_E_INVALID_REQUEST));
267 cert = *d;
270 time_t session::get_peers_certificate_activation_time() const
272 return gnutls_certificate_activation_time_peers( this->s);
275 time_t session::get_peers_certificate_expiration_time() const
277 return gnutls_certificate_expiration_time_peers( this->s);
279 void session::verify_peers_certificate( unsigned int& status) const
281 RETWRAP( gnutls_certificate_verify_peers2( this->s, &status));
285 client_session::client_session() : session( GNUTLS_CLIENT)
289 // client session
290 void client_session::set_server_name (gnutls_server_name_type_t type,
291 const void *name, size_t name_length)
293 RETWRAP( gnutls_server_name_set( this->s, type, name, name_length));
296 bool client_session::get_request_status()
298 return RETWRAP(gnutls_certificate_client_get_request_status (this->s));
301 // server_session
302 void server_session::get_server_name (void *data, size_t * data_length,
303 unsigned int *type, unsigned int indx) const
305 RETWRAP( gnutls_server_name_get( this->s, data, data_length, type, indx));
308 // internal DB stuff
309 static int store_function(void *_db, gnutls_datum_t key, gnutls_datum_t data)
311 try {
312 DB* db = static_cast<DB*>(_db);
314 if (db->store( key, data)==false) return -1;
315 } catch(...) {
316 return -1;
319 return 0;
322 const static gnutls_datum_t null_datum = { NULL, 0 };
324 static gnutls_datum_t retrieve_function(void *_db, gnutls_datum_t key)
326 gnutls_datum_t data;
328 try {
329 DB* db = static_cast<DB*>(_db);
331 if (db->retrieve( key, data)==false) return null_datum;
333 } catch(...) {
334 return null_datum;
337 return data;
340 static int remove_function(void *_db, gnutls_datum_t key)
342 try {
343 DB* db = static_cast<DB*>(_db);
345 if (db->remove( key)==false) return -1;
346 } catch(...) {
347 return -1;
350 return 0;
353 void server_session::set_db( const DB& db)
355 gnutls_db_set_ptr( this->s, const_cast<DB*>(&db));
356 gnutls_db_set_store_function( this->s, store_function);
357 gnutls_db_set_retrieve_function( this->s, retrieve_function);
358 gnutls_db_set_remove_function( this->s, remove_function);
361 void server_session::set_db_cache_expiration (unsigned int seconds)
363 gnutls_db_set_cache_expiration( this->s, seconds);
366 void server_session::db_remove () const
368 gnutls_db_remove_session( this->s);
371 bool server_session::db_check_entry ( gnutls_datum_t &session_data) const
373 int ret = gnutls_db_check_entry( this->s, session_data);
375 if (ret != 0) return true;
376 return false;
379 void session::set_max_handshake_packet_length ( size_t max)
381 gnutls_handshake_set_max_packet_length( this->s, max);
384 void session::clear_credentials()
386 gnutls_credentials_clear( this->s);
389 void session::set_credentials( credentials &cred)
391 RETWRAP(gnutls_credentials_set( this->s, cred.get_type(), cred.ptr()));
394 const char* server_session::get_srp_username() const
396 return gnutls_srp_server_get_username( this->s);
399 const char* server_session::get_psk_username() const
401 return gnutls_psk_server_get_username( this->s);
405 void session::set_transport_ptr( gnutls_transport_ptr_t ptr)
407 gnutls_transport_set_ptr( this->s, ptr);
410 void session::set_transport_ptr( gnutls_transport_ptr_t recv_ptr, gnutls_transport_ptr_t send_ptr)
412 gnutls_transport_set_ptr2( this->s, recv_ptr, send_ptr);
416 gnutls_transport_ptr_t session::get_transport_ptr () const
418 return gnutls_transport_get_ptr (this->s);
421 void session::get_transport_ptr( gnutls_transport_ptr_t & recv_ptr,
422 gnutls_transport_ptr_t & send_ptr) const
424 gnutls_transport_get_ptr2 (this->s, &recv_ptr, &send_ptr);
427 void session::set_transport_lowat( size_t num)
429 gnutls_transport_set_lowat (this->s, num);
432 void session::set_transport_push_function( gnutls_push_func push_func)
434 gnutls_transport_set_push_function ( this->s, push_func);
437 void session::set_transport_pull_function( gnutls_pull_func pull_func)
439 gnutls_transport_set_pull_function ( this->s, pull_func);
442 void session::set_user_ptr( void* ptr)
444 gnutls_session_set_ptr( this->s, ptr);
447 void* session::get_user_ptr( ) const
449 return gnutls_session_get_ptr(this->s);
452 void session::send_openpgp_key( gnutls_openpgp_key_status_t status)
454 gnutls_openpgp_send_key(this->s, status);
458 void session::set_dh_prime_bits( unsigned int bits)
460 gnutls_dh_set_prime_bits( this->s, bits);
463 unsigned int session::get_dh_secret_bits() const
465 return RETWRAP( gnutls_dh_get_secret_bits( this->s));
468 unsigned int session::get_dh_peers_public_bits() const
470 return RETWRAP(gnutls_dh_get_peers_public_bits( this->s));
473 unsigned int session::get_dh_prime_bits() const
475 return RETWRAP( gnutls_dh_get_prime_bits( this->s));
478 void session::get_dh_group( gnutls_datum_t & gen, gnutls_datum_t & prime) const
480 RETWRAP( gnutls_dh_get_group( this->s, &gen, &prime));
483 void session::get_dh_pubkey( gnutls_datum_t & raw_key) const
485 RETWRAP(gnutls_dh_get_pubkey( this->s, &raw_key));
488 void session::get_rsa_export_pubkey( gnutls_datum& exponent, gnutls_datum& modulus) const
490 RETWRAP( gnutls_rsa_export_get_pubkey( this->s, &exponent, &modulus));
493 unsigned int session::get_rsa_export_modulus_bits() const
495 return RETWRAP(gnutls_rsa_export_get_modulus_bits( this->s));
498 void server_session::set_certificate_request( gnutls_certificate_request_t req)
500 gnutls_certificate_server_set_request (this->s, req);
506 gnutls_credentials_type_t session::get_auth_type() const
508 return gnutls_auth_get_type( this->s);
511 gnutls_credentials_type_t session::get_server_auth_type() const
513 return gnutls_auth_server_get_type( this->s);
516 gnutls_credentials_type_t session::get_client_auth_type() const
518 return gnutls_auth_client_get_type( this->s);
522 void* certificate_credentials::ptr() const
524 return this->cred;
527 void certificate_credentials::set_ptr(void* p)
529 this->cred = static_cast<gnutls_certificate_credentials_t> (p);
532 certificate_credentials::~certificate_credentials()
534 gnutls_certificate_free_credentials (this->cred);
537 certificate_credentials::certificate_credentials() : credentials(GNUTLS_CRD_CERTIFICATE)
539 RETWRAP(gnutls_certificate_allocate_credentials ( &this->cred));
542 void certificate_server_credentials::set_params_function( gnutls_params_function* func)
544 gnutls_certificate_set_params_function( this->cred, func);
547 anon_server_credentials::anon_server_credentials() : credentials(GNUTLS_CRD_ANON)
549 RETWRAP(gnutls_anon_allocate_server_credentials( &this->cred));
552 anon_server_credentials::~anon_server_credentials()
554 gnutls_anon_free_server_credentials( this->cred);
557 void anon_server_credentials::set_dh_params( const dh_params& params)
559 gnutls_anon_set_server_dh_params (this->cred, params.get_params_t());
562 void anon_server_credentials::set_params_function ( gnutls_params_function * func)
564 gnutls_anon_set_server_params_function ( this->cred, func);
567 anon_client_credentials::anon_client_credentials() : credentials(GNUTLS_CRD_ANON)
569 RETWRAP(gnutls_anon_allocate_client_credentials( &this->cred));
572 anon_client_credentials::~anon_client_credentials()
574 gnutls_anon_free_client_credentials( this->cred);
577 void certificate_credentials::free_keys ()
579 gnutls_certificate_free_keys( this->cred);
582 void certificate_credentials::free_cas ()
584 gnutls_certificate_free_cas( this->cred);
587 void certificate_credentials::free_ca_names ()
589 gnutls_certificate_free_ca_names( this->cred);
592 void certificate_credentials::free_crls ()
594 gnutls_certificate_free_crls( this->cred);
598 void certificate_credentials::set_dh_params ( const dh_params& params)
600 gnutls_certificate_set_dh_params( this->cred, params.get_params_t());
603 void certificate_credentials::set_rsa_export_params ( const rsa_params & params)
605 gnutls_certificate_set_rsa_export_params( this->cred, params.get_params_t());
608 void certificate_credentials::set_verify_flags ( unsigned int flags)
610 gnutls_certificate_set_verify_flags( this->cred, flags);
613 void certificate_credentials::set_verify_limits ( unsigned int max_bits, unsigned int max_depth)
615 gnutls_certificate_set_verify_limits( this->cred, max_bits, max_depth);
618 void certificate_credentials::set_x509_trust_file(const char *cafile, gnutls_x509_crt_fmt_t type)
620 RETWRAP( gnutls_certificate_set_x509_trust_file( this->cred, cafile, type));
623 void certificate_credentials::set_x509_trust(const gnutls_datum_t & CA, gnutls_x509_crt_fmt_t type)
625 RETWRAP( gnutls_certificate_set_x509_trust_mem( this->cred, &CA, type));
629 void certificate_credentials::set_x509_crl_file( const char *crlfile, gnutls_x509_crt_fmt_t type)
631 RETWRAP( gnutls_certificate_set_x509_crl_file( this->cred, crlfile, type));
634 void certificate_credentials::set_x509_crl(const gnutls_datum_t & CRL, gnutls_x509_crt_fmt_t type)
636 RETWRAP( gnutls_certificate_set_x509_crl_mem( this->cred, &CRL, type));
639 void certificate_credentials::set_x509_key_file(const char *certfile, const char *keyfile, gnutls_x509_crt_fmt_t type)
641 RETWRAP( gnutls_certificate_set_x509_key_file( this->cred, certfile, keyfile, type));
644 void certificate_credentials::set_x509_key(const gnutls_datum_t & CERT, const gnutls_datum_t & KEY, gnutls_x509_crt_fmt_t type)
646 RETWRAP( gnutls_certificate_set_x509_key_mem( this->cred, &CERT, &KEY, type));
649 void certificate_credentials::set_simple_pkcs12_file( const char *pkcs12file,
650 gnutls_x509_crt_fmt_t type, const char *password)
652 RETWRAP( gnutls_certificate_set_x509_simple_pkcs12_file( this->cred, pkcs12file, type, password));
655 void certificate_credentials::set_x509_key ( gnutls_x509_crt_t * cert_list, int cert_list_size,
656 gnutls_x509_privkey_t key)
658 RETWRAP( gnutls_certificate_set_x509_key( this->cred, cert_list, cert_list_size, key));
661 void certificate_credentials::set_x509_trust ( gnutls_x509_crt_t * ca_list, int ca_list_size)
663 RETWRAP( gnutls_certificate_set_x509_trust( this->cred, ca_list, ca_list_size));
666 void certificate_credentials::set_x509_crl ( gnutls_x509_crl_t * crl_list, int crl_list_size)
668 RETWRAP( gnutls_certificate_set_x509_crl( this->cred, crl_list, crl_list_size));
671 void certificate_server_credentials::set_retrieve_function( gnutls_certificate_server_retrieve_function* func)
673 gnutls_certificate_server_set_retrieve_function( this->cred, func);
676 void certificate_client_credentials::set_retrieve_function( gnutls_certificate_client_retrieve_function* func)
678 gnutls_certificate_client_set_retrieve_function( this->cred, func);
681 // SRP
683 srp_server_credentials::srp_server_credentials() : credentials(GNUTLS_CRD_SRP)
685 RETWRAP(gnutls_srp_allocate_server_credentials( &this->cred));
688 srp_server_credentials::~srp_server_credentials()
690 gnutls_srp_free_server_credentials( this->cred);
693 void* srp_server_credentials::ptr() const
695 return this->cred;
698 void srp_server_credentials::set_ptr(void* p)
700 this->cred = static_cast<gnutls_srp_server_credentials_t> (p);
703 srp_client_credentials::srp_client_credentials() : credentials(GNUTLS_CRD_SRP)
705 RETWRAP(gnutls_srp_allocate_client_credentials( &this->cred));
708 srp_client_credentials::~srp_client_credentials()
710 gnutls_srp_free_client_credentials( this->cred);
713 void* srp_client_credentials::ptr() const
715 return this->cred;
718 void srp_client_credentials::set_ptr(void* p)
720 this->cred = static_cast<gnutls_srp_client_credentials_t> (p);
723 void srp_client_credentials::set_credentials( const char* username, const char* password)
725 RETWRAP(gnutls_srp_set_client_credentials (this->cred, username, password));
728 void srp_server_credentials::set_credentials_file (
729 const char *password_file, const char *password_conf_file)
731 RETWRAP( gnutls_srp_set_server_credentials_file( this->cred, password_file, password_conf_file));
735 void srp_server_credentials::set_credentials_function(gnutls_srp_server_credentials_function * func)
737 gnutls_srp_set_server_credentials_function( this->cred, func);
740 void srp_client_credentials::set_credentials_function(gnutls_srp_client_credentials_function * func)
742 gnutls_srp_set_client_credentials_function( this->cred, func);
745 // PSK
747 psk_server_credentials::psk_server_credentials() : credentials(GNUTLS_CRD_PSK)
749 RETWRAP(gnutls_psk_allocate_server_credentials( &this->cred));
752 psk_server_credentials::~psk_server_credentials()
754 gnutls_psk_free_server_credentials( this->cred);
757 void* psk_server_credentials::ptr() const
759 return this->cred;
762 void psk_server_credentials::set_ptr(void* p)
764 this->cred = static_cast<gnutls_psk_server_credentials_t> (p);
767 void psk_server_credentials::set_credentials_file(const char* password_file)
769 RETWRAP(gnutls_psk_set_server_credentials_file( this->cred, password_file));
772 void psk_server_credentials::set_credentials_function(gnutls_psk_server_credentials_function * func)
774 gnutls_psk_set_server_credentials_function( this->cred, func);
777 void psk_server_credentials::set_dh_params( const dh_params &params)
779 gnutls_psk_set_server_dh_params( this->cred, params.get_params_t());
782 void psk_server_credentials::set_params_function(gnutls_params_function * func)
784 gnutls_psk_set_server_params_function (this->cred, func);
789 psk_client_credentials::psk_client_credentials() : credentials(GNUTLS_CRD_PSK)
791 RETWRAP(gnutls_psk_allocate_client_credentials( &this->cred));
794 psk_client_credentials::~psk_client_credentials()
796 gnutls_psk_free_client_credentials( this->cred);
799 void* psk_client_credentials::ptr() const
801 return this->cred;
804 void psk_client_credentials::set_ptr(void* p)
806 this->cred = static_cast<gnutls_psk_client_credentials_t> (p);
809 void psk_client_credentials::set_credentials(const char* username,
810 const gnutls_datum& key, gnutls_psk_key_flags flags)
812 RETWRAP(gnutls_psk_set_client_credentials( this->cred, username, &key, flags));
815 void psk_client_credentials::set_credentials_function(gnutls_psk_client_credentials_function * func)
817 gnutls_psk_set_client_credentials_function( this->cred, func);
821 credentials::credentials(gnutls_credentials_type_t t) : type(t)
825 #if !(defined(__APPLE__) || defined(__MACOS__))
826 /* FIXME: This #if is due to a compile bug in Mac OS X. Give it some
827 time and then remove this cruft. See also
828 includes/gnutls/gnutlsxx.h. */
829 credentials::credentials( credentials& c)
831 this->type = c.type;
832 this->set_ptr( c.ptr());
834 #endif
836 gnutls_credentials_type_t credentials::get_type() const
838 return type;
845 exception::exception( int x)
847 retcode = x;
850 int exception::get_code()
852 return retcode;
855 const char* exception::what() const throw()
857 return gnutls_strerror(retcode);
863 dh_params::dh_params()
865 RETWRAP(gnutls_dh_params_init( &params));
868 dh_params::~dh_params()
870 gnutls_dh_params_deinit(params);
873 void dh_params::import_raw( const gnutls_datum_t & prime,
874 const gnutls_datum_t & generator)
876 RETWRAP( gnutls_dh_params_import_raw( params, &prime, &generator));
879 void dh_params::import_pkcs3( const gnutls_datum_t & pkcs3_params,
880 gnutls_x509_crt_fmt_t format)
882 RETWRAP(gnutls_dh_params_import_pkcs3( params, &pkcs3_params, format));
885 void dh_params::generate( unsigned int bits)
887 RETWRAP(gnutls_dh_params_generate2( params, bits));
890 void dh_params::export_pkcs3( gnutls_x509_crt_fmt_t format, unsigned char *params_data, size_t * params_data_size)
892 RETWRAP( gnutls_dh_params_export_pkcs3( params, format, params_data, params_data_size));
895 void dh_params::export_raw( gnutls_datum_t& prime, gnutls_datum_t &generator)
897 RETWRAP( gnutls_dh_params_export_raw( params, &prime, &generator, NULL));
900 gnutls_dh_params_t dh_params::get_params_t() const
902 return params;
905 dh_params & dh_params::operator=(const dh_params& src)
907 dh_params* dst = new dh_params;
908 int ret;
910 ret = gnutls_dh_params_cpy( dst->params, src.params);
912 if (ret < 0) {
913 delete dst;
914 throw(ret);
917 return *dst;
921 // RSA
923 rsa_params::rsa_params()
925 RETWRAP(gnutls_rsa_params_init( &params));
928 rsa_params::~rsa_params()
930 gnutls_rsa_params_deinit(params);
933 void rsa_params::import_pkcs1( const gnutls_datum_t & pkcs1_params,
934 gnutls_x509_crt_fmt_t format)
936 RETWRAP(gnutls_rsa_params_import_pkcs1( params, &pkcs1_params, format));
939 void rsa_params::generate( unsigned int bits)
941 RETWRAP(gnutls_rsa_params_generate2( params, bits));
944 void rsa_params::export_pkcs1( gnutls_x509_crt_fmt_t format, unsigned char *params_data, size_t * params_data_size)
946 RETWRAP( gnutls_rsa_params_export_pkcs1( params, format, params_data, params_data_size));
949 gnutls_rsa_params_t rsa_params::get_params_t() const
951 return params;
954 rsa_params & rsa_params::operator=(const rsa_params& src)
956 rsa_params* dst = new rsa_params;
957 int ret;
959 ret = gnutls_rsa_params_cpy( dst->params, src.params);
961 if (ret < 0)
962 delete dst;
963 throw(ret);
965 return *dst;
968 void rsa_params::import_raw( const gnutls_datum_t & m,
969 const gnutls_datum_t & e,
970 const gnutls_datum_t & d,
971 const gnutls_datum_t & p,
972 const gnutls_datum_t & q,
973 const gnutls_datum_t & u)
976 RETWRAP(gnutls_rsa_params_import_raw ( params, &m, &e, &d, &p, &q, &u));
980 void rsa_params::export_raw( gnutls_datum_t & m, gnutls_datum_t & e,
981 gnutls_datum_t & d, gnutls_datum_t & p,
982 gnutls_datum_t & q, gnutls_datum_t & u)
984 RETWRAP( gnutls_rsa_params_export_raw ( params, &m, &e, &d, &p, &q, &u, NULL));