]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
GnuTLS Length Hiding patch.
authorAlfredo Pironti <alfredo@pironti.eu>
Tue, 22 Jan 2013 19:05:08 +0000 (20:05 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 23 Jan 2013 19:31:17 +0000 (20:31 +0100)
- Remove random padding; use minimal padding with legacy interface
- With new interface, use LH when possible, that is in CBC mode or with the new padding extension
- Rename priority to "NEW_PADDING"
- gnutls-cli: add command line switch --ranges using LH when possible.
- Update documentation

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
21 files changed:
doc/Makefile.am
doc/cha-gtls-app.texi
doc/cha-intro-tls.texi
doc/invoke-gnutls-cli.texi
lib/Makefile.am
lib/ext/new_record_padding.c
lib/gnutls_cipher.c
lib/gnutls_cipher.h
lib/gnutls_int.h
lib/gnutls_priority.c
lib/gnutls_range.c [new file with mode: 0644]
lib/gnutls_record.c
lib/gnutls_record.h
lib/includes/gnutls/gnutls.h.in
src/cli-args.c
src/cli-args.def
src/cli-args.h
src/cli.c
src/socket.c
src/socket.h
tests/mini-record.c

index c9970e5d14f43724cce177fed340c0b9d04b8cf9..b95354876ec0464777a571a2c6915306e73fb916 100644 (file)
@@ -1522,8 +1522,12 @@ FUNCS += functions/gnutls_random_art
 FUNCS += functions/gnutls_random_art.short
 FUNCS += functions/gnutls_record_check_pending
 FUNCS += functions/gnutls_record_check_pending.short
-FUNCS += functions/gnutls_record_disable_padding
-FUNCS += functions/gnutls_record_disable_padding.short
+FUNCS += functions/gnutls_range_can_use_length_hiding
+FUNCS += functions/gnutls_range_can_use_length_hiding.short
+FUNCS += functions/gnutls_range_send_message
+FUNCS += functions/gnutls_range_send_message.short
+FUNCS += functions/gnutls_record_max_empty_records
+FUNCS += functions/gnutls_record_max_empty_records.short
 FUNCS += functions/gnutls_record_get_direction
 FUNCS += functions/gnutls_record_get_direction.short
 FUNCS += functions/gnutls_record_get_discarded
index 3f8fdd396971e82ba6794e9592b62ab0e447919d..36cc6ae80b04a983332c51057029921321bbf5e3 100644 (file)
@@ -1020,10 +1020,11 @@ This is the default.
 @item %LATEST_RECORD_VERSION @tab
 will use the latest TLS version record version in client hello.
 
-@item %RANDOM_PADDING @tab
-will use random padding to all sent TLS records. This is negotiated
-using an extension. Use @funcref{gnutls_record_get_random_padding_status}
-to check whether this has been negotiated in the current session.
+@item %NEW_PADDING @tab
+will enable the new padding extension negotiation. If the new padding extension
+is negotiated, GnuTLS will use a more efficient length-hiding mechanism.
+Use @funcref{gnutls_range_can_use_length_hiding} to check whether length-hiding
+can be used in the current session.
 
 @end multitable
 @caption{Special priority string keywords.}
index 9674fb4972b81885c348858edb19f8976466fec4..e4ff89c195086d7800bc4e374b43150b58455c35 100644 (file)
@@ -230,10 +230,16 @@ Working Group mailing list and @xcite{CBCATT}.
 @cindex record padding
 @cindex bad_record_mac
 
-The TLS protocol allows for random padding of records in CBC ciphers, to prevent
+The TLS protocol allows for extra padding of records in CBC ciphers, to prevent
 statistical analysis based on the length of exchanged messages (see @xcite{RFC5246} section 6.2.3.2).  
-GnuTLS appears to be one of few implementation that take advantage of this text, 
-and pad records by a random length.
+GnuTLS appears to be one of few implementations that take advantage of this feature: 
+the user can provide some plaintext data with a range of lengths she wishes to hide,
+and GnuTLS adds extra padding to make sure the attacker cannot tell the real plaintext
+length is in a range smaller than the user-provided one.
+Use @funcref{gnutls_range_send_message} to send length-hidden messages and
+@funcref{gnutls_range_can_use_length_hiding} to check whether the current
+session supports length hiding. Using the standard @funcref{gnutls_record_send}
+will only add minimal padding.
 
 The TLS implementation in the Symbian operating system, frequently
 used by Nokia and Sony-Ericsson mobile phones, cannot handle
@@ -244,10 +250,8 @@ the correct MAC for the record.  The client sends a TLS alert
 in error messages such as 'A TLS fatal alert has been received', 'Bad
 record MAC', or both, on the GnuTLS server side.
 
-GnuTLS implements a work around for this problem.  However, it has to
-be enabled specifically.  It can be enabled by using
-@funcref{gnutls_record_disable_padding}, or @funcref{gnutls_priority_set} with
-the @code{%COMPAT} priority string (see @ref{Priority Strings}).
+If compatibility with such devices is a concern, not sending length-hidden messages
+solves the problem by using minimal padding.
 
 If you implement an application that have a configuration file, we
 recommend that you make it possible for users or administrators to
index f268c7690ea94be56d4aa7eae3184c599b0ddcf5..44a1ef3def180553f6300a48389ee93a1d046a61 100644 (file)
@@ -6,7 +6,7 @@
 # 
 # DO NOT EDIT THIS FILE   (invoke-gnutls-cli.texi)
 # 
-# It has been AutoGen-ed  January  1, 2013 at 09:07:50 PM by AutoGen 5.16
+# It has been AutoGen-ed  January 22, 2013 at 05:28:22 PM by AutoGen 5.15
 # From the definitions    ../src/cli-args.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -21,16 +21,9 @@ This software is released under the GNU General Public License, version 3 or lat
 
 
 @anchor{gnutls-cli usage}
-@subheading gnutls-cli help/usage (-h)
-@cindex gnutls-cli help
+@subheading gnutls-cli usage (-h)
 
-This is the automatically generated usage text for gnutls-cli.
-The text printed is the same whether for the @code{help} option (-h) or the @code{more-help} option (-!).  @code{more-help} will print
-the usage text by passing it through a pager program.
-@code{more-help} is disabled on platforms without a working
-@code{fork(2)} function.  The @code{PAGER} environment variable is
-used to select the program, defaulting to @file{more}.  Both will exit
-with a status code of 0.
+This is the automatically generated usage text for gnutls-cli:
 
 @exampleindent 0
 @example
@@ -91,6 +84,7 @@ USAGE:  gnutls-cli [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [hostname]
        --pskkey=str           PSK key (in hex) to use
    -p, --port=str             The port or service to connect to
        --insecure             Don't abort program if server certificate can't be validated
+       --ranges               When possible, use length-hiding padding to prevent traffic analysis
        --benchmark-ciphers    Benchmark individual ciphers
        --benchmark-soft-ciphers  Benchmark individual software ciphers (no hw acceleration)
        --benchmark-tls-kx     Benchmark TLS key exchange methods
@@ -106,25 +100,57 @@ Operands and options may be intermixed.  They will be reordered.
 
 
 
-Simple client program to set up a TLS connection to some other computer.  It
-sets up a TLS connection and forwards data from the standard input to the
-secured socket and vice versa.
+Simple client program to set up a TLS connection to some other computer.
+It sets up a TLS connection and forwards data from the standard input to
+the secured socket and vice versa.
 
 please send bug reports to:  bug-gnutls@@gnu.org
 @end example
 @exampleindent 4
 
-@anchor{gnutls-cli debug}
-@subheading debug option (-d)
+@anchor{gnutls-cli benchmark-ciphers}
+@subheading benchmark-ciphers option
+
+This is the ``benchmark individual ciphers'' option.
+
+
+@anchor{gnutls-cli benchmark-soft-ciphers}
+@subheading benchmark-soft-ciphers option
+
+This is the ``benchmark individual software ciphers (no hw acceleration)'' option.
+
+
+@anchor{gnutls-cli benchmark-tls-ciphers}
+@subheading benchmark-tls-ciphers option
+
+This is the ``benchmark tls ciphers'' option.
+
+
+@anchor{gnutls-cli benchmark-tls-kx}
+@subheading benchmark-tls-kx option
+
+This is the ``benchmark tls key exchange methods'' option.
+
+
+@anchor{gnutls-cli ca-verification}
+@subheading ca-verification option
+
+This is the ``disable ca certificate verification'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is enabled by default.
+@end itemize
+
+This option will disable CA certificate verification. It is to be used with the --dane or --tofu options.
+
+@anchor{gnutls-cli crlf}
+@subheading crlf option
+
+This is the ``send cr lf instead of lf'' option.
 
-This is the ``enable debugging.'' option.
-This option takes an argument number.
-Specifies the debug level.
-@anchor{gnutls-cli tofu}
-@subheading tofu option
 
-This is the ``enable trust on first use authentication'' option.
-This option will, in addition to certificate authentication, perform authentication based on previously seen public keys, a model similar to SSH authentication.
 @anchor{gnutls-cli dane}
 @subheading dane option
 
@@ -132,88 +158,256 @@ This is the ``enable dane certificate verification (dnssec)'' option.
 This option will, in addition to certificate authentication using 
 the trusted CAs, verify the server certificates using on the DANE information
 available via DNSSEC.
+
+@anchor{gnutls-cli debug}
+@subheading debug option (-d)
+
+This is the ``enable debugging.'' option.
+Specifies the debug level.
+
+@anchor{gnutls-cli dh-bits}
+@subheading dh-bits option
+
+This is the ``the minimum number of bits allowed for dh'' option.
+This option sets the minimum number of bits allowed for a Diffie-Hellman key exchange. You may want to lower the default value if the peer sends a weak prime and you get an connection error with unacceptable prime.
+
+@anchor{gnutls-cli disable-extensions}
+@subheading disable-extensions option
+
+This is the ``disable all the tls extensions'' option.
+This option disables all TLS extensions. Deprecated option. Use the priority string.
+
+@anchor{gnutls-cli fingerprint}
+@subheading fingerprint option (-f)
+
+This is the ``send the openpgp fingerprint, instead of the key'' option.
+
+
+@anchor{gnutls-cli heartbeat}
+@subheading heartbeat option (-b)
+
+This is the ``activate heartbeat support'' option.
+
+
+@anchor{gnutls-cli insecure}
+@subheading insecure option
+
+This is the ``don't abort program if server certificate can't be validated'' option.
+
+
+@anchor{gnutls-cli list}
+@subheading list option (-l)
+
+This is the ``print a list of the supported algorithms and modes'' option.
+Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.
+
 @anchor{gnutls-cli local-dns}
 @subheading local-dns option
 
 This is the ``use the local dns server for dnssec resolving.'' option.
 This option will use the local DNS server for DNSSEC.
 This is disabled by default due to many servers not allowing DNSSEC.
-@anchor{gnutls-cli ca-verification}
-@subheading ca-verification option
 
-This is the ``disable ca certificate verification'' option.
+@anchor{gnutls-cli mtu}
+@subheading mtu option
+
+This is the ``set mtu for datagram tls'' option.
+
+
+@anchor{gnutls-cli noticket}
+@subheading noticket option
+
+This is the ``don't accept session tickets'' option.
 
-@noindent
-This option has some usage constraints.  It:
-@itemize @bullet
-@item
-is enabled by default.
-@end itemize
 
-This option will disable CA certificate verification. It is to be used with the --dane or --tofu options.
 @anchor{gnutls-cli ocsp}
 @subheading ocsp option
 
 This is the ``enable ocsp certificate verification'' option.
 This option will enable verification of the peer's certificate using ocsp
-@anchor{gnutls-cli resume}
-@subheading resume option (-r)
 
-This is the ``establish a session and resume'' option.
-Connect, establish a session, reconnect and resume.
-@anchor{gnutls-cli rehandshake}
-@subheading rehandshake option (-e)
+@anchor{gnutls-cli pgpcertfile}
+@subheading pgpcertfile option
 
-This is the ``establish a session and rehandshake'' option.
-Connect, establish a session and rehandshake immediately.
-@anchor{gnutls-cli starttls}
-@subheading starttls option (-s)
+This is the ``pgp public key (certificate) file to use'' option.
 
-This is the ``connect, establish a plain session and start tls.'' option.
-The TLS session will be initiated when EOF or a SIGALRM is received.
-@anchor{gnutls-cli disable-extensions}
-@subheading disable-extensions option
 
-This is the ``disable all the tls extensions'' option.
-This option disables all TLS extensions. Deprecated option. Use the priority string.
-@anchor{gnutls-cli dh-bits}
-@subheading dh-bits option
+@anchor{gnutls-cli pgpkeyfile}
+@subheading pgpkeyfile option
+
+This is the ``pgp key file to use'' option.
+
+
+@anchor{gnutls-cli pgpkeyring}
+@subheading pgpkeyring option
+
+This is the ``pgp key ring file to use'' option.
+
+
+@anchor{gnutls-cli pgpsubkey}
+@subheading pgpsubkey option
+
+This is the ``pgp subkey to use (hex or auto)'' option.
+
+
+@anchor{gnutls-cli port}
+@subheading port option (-p)
+
+This is the ``the port or service to connect to'' option.
+
+
+@anchor{gnutls-cli print-cert}
+@subheading print-cert option
+
+This is the ``print peer's certificate in pem format'' option.
+
 
-This is the ``the minimum number of bits allowed for dh'' option.
-This option takes an argument number.
-This option sets the minimum number of bits allowed for a Diffie-Hellman key exchange. You may want to lower the default value if the peer sends a weak prime and you get an connection error with unacceptable prime.
 @anchor{gnutls-cli priority}
 @subheading priority option
 
 This is the ``priorities string'' option.
-This option takes an argument string.
 TLS algorithms and protocols to enable. You can
 use predefined sets of ciphersuites such as PERFORMANCE,
 NORMAL, SECURE128, SECURE256.
 
 Check  the  GnuTLS  manual  on  section  ``Priority strings'' for more
 information on allowed keywords
-@anchor{gnutls-cli list}
-@subheading list option (-l)
 
-This is the ``print a list of the supported algorithms and modes'' option.
-Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.
+@anchor{gnutls-cli pskkey}
+@subheading pskkey option
+
+This is the ``psk key (in hex) to use'' option.
+
+
+@anchor{gnutls-cli pskusername}
+@subheading pskusername option
+
+This is the ``psk username to use'' option.
+
+
+@anchor{gnutls-cli ranges}
+@subheading ranges option
+
+This is the ``when possible, use length-hiding padding to prevent traffic analysis'' option.
+
+
+@anchor{gnutls-cli recordsize}
+@subheading recordsize option
+
+This is the ``the maximum record size to advertize'' option.
+
+
+@anchor{gnutls-cli rehandshake}
+@subheading rehandshake option (-e)
+
+This is the ``establish a session and rehandshake'' option.
+Connect, establish a session and rehandshake immediately.
+
+@anchor{gnutls-cli resume}
+@subheading resume option (-r)
+
+This is the ``establish a session and resume'' option.
+Connect, establish a session, reconnect and resume.
+
+@anchor{gnutls-cli srppasswd}
+@subheading srppasswd option
+
+This is the ``srp password to use'' option.
+
+
+@anchor{gnutls-cli srpusername}
+@subheading srpusername option
+
+This is the ``srp username to use'' option.
+
+
+@anchor{gnutls-cli srtp-profiles}
+@subheading srtp-profiles option
+
+This is the ``offer srtp profiles'' option.
+
+
+@anchor{gnutls-cli starttls}
+@subheading starttls option (-s)
+
+This is the ``connect, establish a plain session and start tls.'' option.
+The TLS session will be initiated when EOF or a SIGALRM is received.
+
+@anchor{gnutls-cli tofu}
+@subheading tofu option
+
+This is the ``enable trust on first use authentication'' option.
+This option will, in addition to certificate authentication, perform authentication based on previously seen public keys, a model similar to SSH authentication.
+
+@anchor{gnutls-cli udp}
+@subheading udp option (-u)
+
+This is the ``use dtls (datagram tls) over udp'' option.
+
+
+@anchor{gnutls-cli verbose}
+@subheading verbose option (-V)
+
+This is the ``more verbose output'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+
+
+@anchor{gnutls-cli x509cafile}
+@subheading x509cafile option
+
+This is the ``certificate file or pkcs #11 url to use'' option.
+
+
+@anchor{gnutls-cli x509certfile}
+@subheading x509certfile option
+
+This is the ``x.509 certificate file or pkcs #11 url to use'' option.
+
+
+@anchor{gnutls-cli x509crlfile}
+@subheading x509crlfile option
+
+This is the ``crl file to use'' option.
+
+
+@anchor{gnutls-cli x509fmtder}
+@subheading x509fmtder option
+
+This is the ``use der format for certificates to read from'' option.
+
+
+@anchor{gnutls-cli x509keyfile}
+@subheading x509keyfile option
+
+This is the ``x.509 key file or pkcs #11 url to use'' option.
+
 @anchor{gnutls-cli exit status}
 @subheading gnutls-cli exit status
 
 One of the following exit values will be returned:
 @table @samp
-@item 0 (EXIT_SUCCESS)
+@item 0
 Successful program execution.
-@item 1 (EXIT_FAILURE)
+@item 1
 The operation failed or the command syntax was not valid.
 @end table
+
+
 @anchor{gnutls-cli See Also}
 @subheading gnutls-cli See Also
+
 gnutls-cli-debug(1), gnutls-serv(1)
 
+
 @anchor{gnutls-cli Examples}
 @subheading gnutls-cli Examples
+
 @subheading Connecting using PSK authentication
 To connect to a server using PSK authentication, you need to enable the choice of PSK by using a cipher priority parameter such as in the example below. 
 @example
index 8edd15dda015c63a3a3f3ddf95acfb73f9936f4d..816b3c527188d1f071b2e6ee1b753d01a27eb500 100644 (file)
@@ -61,7 +61,8 @@ SRP_COBJECTS = gnutls_srp.c
 
 PSK_COBJECTS = gnutls_psk.c
 
-COBJECTS = gnutls_record.c gnutls_compress.c debug.c gnutls_cipher.c   \
+COBJECTS = gnutls_range.c gnutls_record.c \
+       gnutls_compress.c debug.c gnutls_cipher.c       \
        gnutls_mbuffers.c gnutls_buffers.c gnutls_handshake.c           \
        gnutls_num.c gnutls_errors.c gnutls_dh.c gnutls_kx.c            \
        gnutls_priority.c gnutls_hash_int.c gnutls_cipher_int.c         \
index 2b1da1414a3ab1cce24b4ac8dac39c33ba8787bf..056ad5e5d874d755d81053fa4b79d342c8b80119 100644 (file)
@@ -130,16 +130,3 @@ int ret;
 }
 
 
-/**
- * gnutls_record_get_random_padding_status:
- * @session: is a #gnutls_session_t structure.
- *
- * Returns: non-zero if the new padding scheme is enabled.
- *
- **/
-int
-gnutls_record_get_random_padding_status (gnutls_session_t session)
-{
-  return session->security_parameters.new_record_padding;
-}
-
index 9d24d30a95bd4116e8787ac89d00ec634aa6c5ca..15ee5b0f057de71ccf9c0e50a9edd7837492f76d 100644 (file)
@@ -43,6 +43,7 @@
 static int compressed_to_ciphertext (gnutls_session_t session,
                                    uint8_t * cipher_data, int cipher_size,
                                    gnutls_datum_t *compressed,
+                                   size_t target_size,
                                    content_type_t _type, 
                                    record_parameters_st * params);
 static int ciphertext_to_compressed (gnutls_session_t session,
@@ -61,6 +62,7 @@ static int
 compressed_to_ciphertext_new (gnutls_session_t session,
                                uint8_t * cipher_data, int cipher_size,
                                gnutls_datum_t *compressed,
+                               size_t target_size,
                                content_type_t type, 
                                record_parameters_st * params);
 
@@ -86,12 +88,11 @@ is_read_comp_null (record_parameters_st * record_params)
 /* returns ciphertext which contains the headers too. This also
  * calculates the size in the header field.
  * 
- * If random pad != 0 then the random pad data will be appended.
  */
 int
 _gnutls_encrypt (gnutls_session_t session, const uint8_t * headers,
                  size_t headers_size, const uint8_t * data,
-                 size_t data_size, uint8_t * ciphertext,
+                 size_t data_size, size_t target_size, uint8_t * ciphertext,
                  size_t ciphertext_size, content_type_t type, 
                  record_parameters_st * params)
 {
@@ -130,11 +131,11 @@ _gnutls_encrypt (gnutls_session_t session, const uint8_t * headers,
   if (session->security_parameters.new_record_padding != 0)
     ret = compressed_to_ciphertext_new (session, &ciphertext[headers_size],
                                         ciphertext_size - headers_size,
-                                        &comp, type, params);
+                                        &comp, target_size, type, params);
   else
     ret = compressed_to_ciphertext (session, &ciphertext[headers_size],
                                     ciphertext_size - headers_size,
-                                    &comp, type, params);
+                                    &comp, target_size, type, params);
 
   if (free_comp)
     gnutls_free(comp.data);
@@ -228,32 +229,15 @@ calc_enc_length_block (gnutls_session_t session, int data_size,
                  int hash_size, uint8_t * pad, 
                  unsigned auth_cipher, uint16_t blocksize)
 {
-  uint8_t rnd = *pad;
-  unsigned int length;
-
-  *pad = 0;
-
-  /* make rnd a multiple of blocksize */
-  if (session->security_parameters.version == GNUTLS_SSL3)
-    {
-      rnd = 0;
-    }
-  
-  if (rnd > 0)
-    {
-      rnd = (rnd / blocksize) * blocksize;
-      /* added to avoid the case of pad calculated 0
-       * seen below for pad calculation.
-       */
-      if (rnd > blocksize)
-        rnd -= blocksize;
-    }
+  /* pad is the LH pad the user wants us to add. Besides
+   * this LH pad, we only add minimal padding
+   */
+  unsigned int pre_length = data_size + hash_size + *pad;
 
-  length = data_size + hash_size;
+  *pad = (uint8_t) (blocksize - (pre_length % blocksize)) + *pad;
 
-  *pad = (uint8_t) (blocksize - (length % blocksize)) + rnd;
+  unsigned int length = data_size + hash_size + *pad;
 
-  length += *pad;
   if (_gnutls_version_has_explicit_iv
       (session->security_parameters.version))
     length += blocksize;    /* for the IV */
@@ -315,11 +299,12 @@ static int
 compressed_to_ciphertext (gnutls_session_t session,
                                uint8_t * cipher_data, int cipher_size,
                                gnutls_datum_t *compressed,
+                               size_t target_size,
                                content_type_t type, 
                                record_parameters_st * params)
 {
   uint8_t * tag_ptr = NULL;
-  uint8_t pad = 0;
+  uint8_t pad = target_size - compressed->size;
   int length, length_to_encrypt, ret;
   uint8_t preamble[MAX_PREAMBLE_SIZE];
   int preamble_size;
@@ -331,7 +316,7 @@ compressed_to_ciphertext (gnutls_session_t session,
   int ver = gnutls_protocol_get_version (session);
   int explicit_iv = _gnutls_version_has_explicit_iv (session->security_parameters.version);
   int auth_cipher = _gnutls_auth_cipher_is_aead(&params->write.cipher_state);
-  uint8_t nonce[MAX_CIPHER_BLOCK_SIZE+1];
+  uint8_t nonce[MAX_CIPHER_BLOCK_SIZE];
 
 
   _gnutls_hard_log("ENC[%p]: cipher: %s, MAC: %s, Epoch: %u\n",
@@ -347,18 +332,12 @@ compressed_to_ciphertext (gnutls_session_t session,
    */
   if (block_algo == CIPHER_BLOCK)
     {
-      /* Call _gnutls_rnd() once. Get data used for the IV + 1 for 
-       * the random padding.
+      /* Call _gnutls_rnd() once. Get data used for the IV
        */
-      ret = _gnutls_rnd (GNUTLS_RND_NONCE, nonce, blocksize+1);
+      ret = _gnutls_rnd (GNUTLS_RND_NONCE, nonce, blocksize);
       if (ret < 0)
         return gnutls_assert_val(ret);
 
-      /* We don't use long padding if requested or if we are in DTLS.
-       */
-      if (session->internals.priorities.no_padding == 0 && !IS_DTLS(session))
-        pad = nonce[blocksize];
-
       length_to_encrypt = length =
         calc_enc_length_block (session, compressed->size, tag_size, &pad,
                                auth_cipher, blocksize);
@@ -461,11 +440,12 @@ static int
 compressed_to_ciphertext_new (gnutls_session_t session,
                                uint8_t * cipher_data, int cipher_size,
                                gnutls_datum_t *compressed,
+                               size_t target_size,
                                content_type_t type, 
                                record_parameters_st * params)
 {
   uint8_t * tag_ptr = NULL;
-  uint16_t pad = 0;
+  uint16_t pad = target_size - compressed->size;
   int length, length_to_encrypt, ret;
   uint8_t preamble[MAX_PREAMBLE_SIZE];
   int preamble_size;
@@ -477,24 +457,18 @@ compressed_to_ciphertext_new (gnutls_session_t session,
   int ver = gnutls_protocol_get_version (session);
   int explicit_iv = _gnutls_version_has_explicit_iv (session->security_parameters.version);
   int auth_cipher = _gnutls_auth_cipher_is_aead(&params->write.cipher_state);
-  uint8_t nonce[MAX_CIPHER_BLOCK_SIZE+2];
+  uint8_t nonce[MAX_CIPHER_BLOCK_SIZE];
 
   _gnutls_hard_log("ENC[%p]: cipher: %s, MAC: %s, Epoch: %u\n",
     session, gnutls_cipher_get_name(params->cipher_algorithm), gnutls_mac_get_name(params->mac_algorithm),
     (unsigned int)params->epoch);
 
-  /* Call _gnutls_rnd() once. Get data used for the IV + 2 for 
-   * the random padding.
+  /* Call _gnutls_rnd() once. Get data used for the IV
    */
-  ret = _gnutls_rnd (GNUTLS_RND_NONCE, nonce, blocksize+2);
+  ret = _gnutls_rnd (GNUTLS_RND_NONCE, nonce, blocksize);
   if (ret < 0)
     return gnutls_assert_val(ret);
 
-  /* We don't use long padding if requested.
-   */
-  if (session->internals.priorities.no_padding == 0)
-    memcpy(&pad, &nonce[blocksize], 2);
-
   /* cipher_data points to the start of data to be encrypted */
   data_ptr = cipher_data;
 
@@ -548,16 +522,13 @@ compressed_to_ciphertext_new (gnutls_session_t session,
 
   DECR_LEN(cipher_size, 2);
 
-  pad %= (cipher_size - (compressed->size + tag_size));
-
   if (block_algo == CIPHER_BLOCK) /* make pad a multiple of blocksize */
     {
       unsigned t = (2 + pad + compressed->size + tag_size) % blocksize;
-      
-      if (pad > t)
-        pad -= t;
-      else
-        pad += blocksize - t;
+      if (t > 0)
+        {
+         pad += blocksize - t;
+        }
     }
   
   _gnutls_write_uint16 (pad, data_ptr);
index 9d0da641acae3d8215052acecca6c3ce8d1ac5e5..31e5336fa9fea12a6c2f1142b055758369873748 100644 (file)
@@ -22,7 +22,7 @@
 
 int _gnutls_encrypt (gnutls_session_t session, const uint8_t * headers,
                      size_t headers_size, const uint8_t * data,
-                     size_t data_size, uint8_t * ciphertext,
+                     size_t data_size, size_t target_size, uint8_t * ciphertext,
                      size_t ciphertext_size, content_type_t type,
                      record_parameters_st * params);
 
index 972d6b704646400e3b5ea2d8f6cbe7f32eddecc5..84064ea24261a8fc61b04b35c09809eb58745587 100644 (file)
@@ -606,9 +606,9 @@ struct gnutls_priority_st
 
   /* to disable record padding */
   unsigned int no_extensions:1;
-  unsigned int no_padding:1;
   unsigned int allow_large_records:1;
   unsigned int new_record_padding:1;
+  unsigned int max_empty_records;
   safe_renegotiation_t sr;
   unsigned int ssl3_record_version:1;
   unsigned int server_precedence:1;
@@ -618,8 +618,12 @@ struct gnutls_priority_st
   unsigned int additional_verify_flags;
 };
 
+/* Allow around 50KB of length-hiding padding
+ * when using legacy padding,
+ * or around 3.2MB when using new padding. */
+#define DEFAULT_MAX_EMPTY_RECORDS 200
+
 #define ENABLE_COMPAT(x) \
-              (x)->no_padding = 1; \
               (x)->allow_large_records = 1; \
               (x)->allow_weak_keys = 1
 
index a2085f48f2c58d2f1752fdff17884162019d45d5..9f47f0a2da87d5f4e66555f5ef913ed39596b4aa 100644 (file)
@@ -813,6 +813,8 @@ gnutls_priority_init (gnutls_priority_t * priority_cache,
   (*priority_cache)->sr = SR_PARTIAL;
   (*priority_cache)->ssl3_record_version = 1;
 
+  (*priority_cache)->max_empty_records = DEFAULT_MAX_EMPTY_RECORDS;
+
   if (priorities == NULL)
     priorities = LEVEL_NORMAL;
 
@@ -1040,7 +1042,7 @@ gnutls_priority_init (gnutls_priority_t * priority_cache,
               (*priority_cache)->server_precedence = 1;
             }
           else if (strcasecmp (&broken_list[i][1],
-                               "RANDOM_PADDING") == 0)
+                               "NEW_PADDING") == 0)
             {
               (*priority_cache)->new_record_padding = 1;
             }
diff --git a/lib/gnutls_range.c b/lib/gnutls_range.c
new file mode 100644 (file)
index 0000000..88d1d21
--- /dev/null
@@ -0,0 +1,293 @@
+/*
+ * Copyright (C) 2012 INRIA Paris-Rocquencourt
+ *
+ * Author: Alfredo Pironti
+ *
+ * This file is part of GnuTLS.
+ *
+ * The GnuTLS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "gnutls_int.h"
+#include "gnutls_errors.h"
+#include "algorithms.h"
+#include "gnutls_constate.h"
+#include "gnutls_record.h"
+
+ssize_t
+min (ssize_t a, ssize_t b)
+{
+  if (a < b)
+    return a;
+  else
+    return b;
+}
+
+void
+_gnutls_set_range (gnutls_range_st * dst, const size_t low, const size_t high)
+{
+  dst->low = low;
+  dst->high = high;
+  return;
+}
+
+/*
+ * Returns how much LH pad we can put in this fragment, given we'll
+ * put at least data_length bytes of user data.
+ */
+ssize_t
+_gnutls_range_max_lh_pad (gnutls_session_t session, ssize_t data_length, ssize_t max_frag)
+{
+  int ret;
+  record_parameters_st *record_params;
+
+  ret = _gnutls_epoch_get (session, EPOCH_WRITE_CURRENT, &record_params);
+  if (ret < 0)
+    {
+         return gnutls_assert_val (GNUTLS_E_INVALID_REQUEST);
+    }
+
+  ssize_t max_pad;
+  unsigned int fixed_pad;
+
+  if (session->security_parameters.new_record_padding != 0)
+    {
+         max_pad = MAX_USER_SEND_SIZE (session);
+         fixed_pad = 2;
+    }
+  else
+    {
+         max_pad = MAX_PAD_SIZE;
+         fixed_pad = 1;
+    }
+
+  ssize_t this_pad = min(max_pad,max_frag - data_length);
+
+  ssize_t block_size =
+    gnutls_cipher_get_block_size (record_params->cipher_algorithm);
+  ssize_t tag_size =
+    _gnutls_auth_cipher_tag_len (&record_params->write.cipher_state);
+  ssize_t overflow;
+  switch (_gnutls_cipher_is_block (record_params->cipher_algorithm))
+    {
+    case CIPHER_STREAM:
+      return this_pad;
+
+    case CIPHER_BLOCK:
+         overflow = (data_length + this_pad + tag_size + fixed_pad) % block_size;
+         if (overflow > this_pad)
+           {
+                 return this_pad;
+           }
+         else
+           {
+             return this_pad - overflow;
+           }
+    default:
+      return gnutls_assert_val (GNUTLS_E_INTERNAL_ERROR);
+    }
+}
+
+/**
+ * gnutls_range_can_use_length_hiding:
+ * @session: is a #gnutls_session_t structure.
+ *
+ * Returns true (1) if the current session supports length-hiding
+ * padding, false (0) if the current session does not. Returns
+ * a negative value in case of error.
+ * If the session supports length-hiding padding, you can
+ * invoke #gnutls_range_send_message to send a message whose
+ * length is hidden in the given range. If the session does not
+ * support length hiding padding, you can use the standard
+ * #gnutls_record_send function, or #gnutls_range_send_message
+ * making sure that the range is the same as the length of the
+ * message you are trying to send.
+ **/
+int
+gnutls_range_can_use_length_hiding (gnutls_session_t session)
+{
+  int ret;
+  record_parameters_st *record_params;
+
+  ret = _gnutls_epoch_get (session, EPOCH_WRITE_CURRENT, &record_params);
+  if (ret < 0)
+    {
+         return gnutls_assert_val (GNUTLS_E_INVALID_REQUEST);
+    }
+
+  if (session->security_parameters.new_record_padding != 0)
+    {
+         return 1;
+    }
+
+  if (session->security_parameters.version == GNUTLS_SSL3)
+    {
+         return 0;
+    }
+
+  switch (_gnutls_cipher_is_block (record_params->cipher_algorithm))
+    {
+    case CIPHER_STREAM:
+      return 0;
+    case CIPHER_BLOCK:
+      return 1;
+    default:
+      return gnutls_assert_val (GNUTLS_E_INTERNAL_ERROR);
+    }
+}
+
+ssize_t
+_gnutls_range_split (gnutls_session_t session,
+                     const gnutls_range_st orig,
+                     gnutls_range_st * small_range,
+                     gnutls_range_st * rem_range)
+{
+  int ret;
+  ssize_t max_frag = MAX_USER_SEND_SIZE (session);
+  ssize_t orig_low = (ssize_t) orig.low;
+  ssize_t orig_high = (ssize_t) orig.high;
+
+  if (orig_high == orig_low)
+       {
+          int length = min (orig_high, max_frag);
+          int rem = orig_high - length;
+          _gnutls_set_range (small_range, length, length);
+          _gnutls_set_range (rem_range, rem, rem);
+          return 0;
+    }
+  else
+    {
+         if (orig_low >= max_frag)
+           {
+                 _gnutls_set_range (small_range, max_frag, max_frag);
+                 _gnutls_set_range (rem_range, orig_low - max_frag,
+                                 orig_high - max_frag);
+           }
+         else
+           {
+                 ret = _gnutls_range_max_lh_pad(session,orig_low,max_frag);
+                 if (ret < 0) {
+                         return ret; // already gnutls_assert_val'd
+                 }
+                 ssize_t this_pad = min(ret,orig_high - orig_low);
+
+                 _gnutls_set_range(small_range, orig_low, orig_low + this_pad);
+                 _gnutls_set_range(rem_range, 0, orig_high - (orig_low + this_pad));
+           }
+      return 0;
+    }
+}
+
+size_t
+_gnutls_range_fragment (size_t data_size, gnutls_range_st cur,
+                        gnutls_range_st next)
+{
+  return min (cur.high, data_size - next.low);
+}
+
+/**
+ * gnutls_range_send_message:
+ * @session: is a #gnutls_session_t structure.
+ * @data: contains the data to send.
+ * @data_size: is the length of the data.
+ * @range: is the range of lengths in which the real data length must be hidden.
+ *
+ * This function operates like #gnutls_record_send but, while
+ * #gnutls_record_send adds minimal padding to each TLS record,
+ * this function uses the TLS extra-padding feature to conceal the real
+ * data size within the range of lengths provided.
+ * Some TLS sessions do not support extra padding (e.g. stream ciphers in standard
+ * TLS or SSL3 sessions). To know whether the current session supports extra
+ * padding, and hence length hiding, use the #gnutls_range_can_use_length_hiding
+ * function.
+ *
+ * Returns: The number of bytes sent (that is data_size in a successful invocation),
+ * or a negative error code.
+ **/
+ssize_t
+gnutls_range_send_message (gnutls_session_t session, const void *data,
+                           size_t data_size, const gnutls_range_st range)
+{
+  size_t sent = 0;
+  size_t next_fragment_length;
+  ssize_t ret;
+  gnutls_range_st cur_range, next_range;
+
+  // sanity check on range and data size
+  if (range.low > range.high ||
+      data_size < range.low || data_size > range.high)
+    {
+         return gnutls_assert_val (GNUTLS_E_INVALID_REQUEST);
+    }
+
+  ret = gnutls_range_can_use_length_hiding(session);
+  if (ret < 0)
+    {
+         return ret; // already gnutls_assert_val'd
+    }
+
+  if (ret == 0 && range.low != range.high)
+    {
+         // Cannot use LH, but a range was given
+         return gnutls_assert_val (GNUTLS_E_INVALID_REQUEST);
+    }
+
+  _gnutls_set_range (&cur_range, range.low, range.high);
+
+  _gnutls_record_log
+    ("RANGE: Preparing message with size %d, range (%d,%d)\n",
+     (int) data_size, (int) range.low, (int) range.high);
+
+  while (cur_range.high != 0)
+    {
+      ret =
+        _gnutls_range_split (session, cur_range, &cur_range,
+                             &next_range);
+      if (ret < 0)
+        {
+          return ret;           // already gnutls_assert_val'd
+        }
+
+      next_fragment_length =
+        _gnutls_range_fragment (data_size, cur_range, next_range);
+
+      _gnutls_record_log
+        ("RANGE: Next fragment size: %d (%d,%d); remaining range: (%d,%d)\n",
+         (int) next_fragment_length, (int) cur_range.low,
+         (int) cur_range.high, (int) next_range.low, (int) next_range.high);
+
+      ret = _gnutls_send_tlen_int (session, GNUTLS_APPLICATION_DATA, -1,
+                                   EPOCH_WRITE_CURRENT,
+                                   &(((char *) data)[sent]),
+                                   next_fragment_length, MBUFFER_FLUSH,
+                                   cur_range.high);
+      if (ret < 0)
+        {
+          return ret;           // already gnutls_assert_val'd
+        }
+      if (ret != (ssize_t) next_fragment_length)
+        {
+          _gnutls_record_log
+            ("RANGE: ERROR: ret = %d; next_fragment_length = %d\n", (int) ret,
+             (int) next_fragment_length);
+          return gnutls_assert_val (GNUTLS_E_INTERNAL_ERROR);
+        }
+      sent += next_fragment_length;
+      data_size -= next_fragment_length;
+      _gnutls_set_range (&cur_range, next_range.low, next_range.high);
+    }
+
+  return sent;
+}
index 1501be9ecadcf4ef9cdf903e9e00004eadce9131..5162464fc8634f9d3336935923c86882db01d033 100644 (file)
@@ -66,23 +66,25 @@ struct tls_record_st {
 };
 
 /**
- * gnutls_record_disable_padding:
+ * gnutls_record_max_empty_records:
  * @session: is a #gnutls_session_t structure.
+ * @i: is the desired value of maximum empty records that can be accepted in a row.
  *
- * Used to disabled padding in TLS 1.0 and above.  Normally you do not
- * need to use this function, but there are buggy clients that
- * complain if a server pads the encrypted data.  This of course will
- * disable protection against statistical attacks on the data.
- *
- * Normally only servers that require maximum compatibility with everything
- * out there, need to call this function.
+ * Used to set the maximum number of empty fragments that can be accepted
+ * in a row. Accepting many empty fragments is useful for receiving length-hidden
+ * content, where empty fragments filled with pad are sent to hide the real
+ * length of a message. However, a malicious peer could send empty fragments to
+ * mount a DoS attack, so as a safety measure, a maximum number of empty fragments
+ * is accepted by default. If you know your application must accept a given number
+ * of empty fragments in a row, you can use this function to set the desired value.
  **/
 void
-gnutls_record_disable_padding (gnutls_session_t session)
+gnutls_record_max_empty_records (gnutls_session_t session, const unsigned int i)
 {
-  session->internals.priorities.no_padding = 1;
+  session->internals.priorities.max_empty_records = i;
 }
 
+
 /**
  * gnutls_transport_set_ptr:
  * @session: is a #gnutls_session_t structure.
@@ -332,6 +334,15 @@ _gnutls_send_int (gnutls_session_t session, content_type_t type,
                   gnutls_handshake_description_t htype,
                   unsigned int epoch_rel, const void *_data,
                   size_t data_size, unsigned int mflags)
+{
+  return _gnutls_send_tlen_int(session,type,htype,epoch_rel,_data,data_size,mflags,data_size);
+}
+
+ssize_t
+_gnutls_send_tlen_int (gnutls_session_t session, content_type_t type,
+               gnutls_handshake_description_t htype,
+               unsigned int epoch_rel, const void *_data,
+               size_t data_size, unsigned int mflags, size_t target_length)
 {
   mbuffer_st *bufel;
   ssize_t cipher_size;
@@ -384,8 +395,8 @@ _gnutls_send_int (gnutls_session_t session, content_type_t type,
     memcpy(&headers[3], &record_state->sequence_number.i, 8);
 
   _gnutls_record_log
-    ("REC[%p]: Preparing Packet %s(%d) with length: %d\n", session,
-     _gnutls_packet2str (type), type, (int) data_size);
+    ("REC[%p]: Preparing Packet %s(%d) with length: %d and target length: %d\n", session,
+     _gnutls_packet2str (type), type, (int) data_size, (int) target_length);
 
   if (data_size > MAX_USER_SEND_SIZE(session))
     {
@@ -421,7 +432,7 @@ _gnutls_send_int (gnutls_session_t session, content_type_t type,
 
       ret =
         _gnutls_encrypt (session, headers, header_size, data,
-                         send_data_size, _mbuffer_get_udata_ptr (bufel),
+                         send_data_size, target_length, _mbuffer_get_udata_ptr (bufel),
                          cipher_size, type, record_params);
       if (ret <= 0)
         {
@@ -951,8 +962,6 @@ gnutls_datum_t raw; /* raw headers */
   return 0;
 }
 
-#define MAX_EMPTY_PACKETS_SEQUENCE 4
-
 /* @ms: is the number of milliseconds to wait for data. Use zero for indefinite.
  *
  * This will receive record layer packets and add them to 
@@ -970,14 +979,14 @@ _gnutls_recv_in_buffers (gnutls_session_t session, content_type_t type,
   mbuffer_st* bufel = NULL, *decrypted = NULL;
   gnutls_datum_t t;
   int ret;
-  int empty_packet = 0;
+  unsigned int empty_fragments = 0;
   record_parameters_st *record_params;
   record_state_st *record_state;
   struct tls_record_st record;
 
 begin:
 
-  if (empty_packet > MAX_EMPTY_PACKETS_SEQUENCE)
+  if (empty_fragments > session->internals.priorities.max_empty_records)
     {
       gnutls_assert ();
       return GNUTLS_E_TOO_MANY_EMPTY_PACKETS;
@@ -1118,7 +1127,7 @@ begin:
   if (_mbuffer_get_udata_size(decrypted) == 0)
     {
       _mbuffer_xfree(&decrypted);
-      empty_packet++;
+      empty_fragments++;
       goto begin;
     }
 
index 12cc31a5923c8dc166ea7e9c9d648736cf1ae3d6..8db38f290fcc057eb132a05740f4d8238b08425b 100644 (file)
 #include <gnutls/gnutls.h>
 #include <gnutls_buffers.h>
 
+ssize_t _gnutls_send_tlen_int (gnutls_session_t session, content_type_t type,
+                               gnutls_handshake_description_t htype,
+                               unsigned int epoch_rel, const void *data,
+                               size_t sizeofdata, unsigned int mflags,
+                               size_t targetlength);
 ssize_t _gnutls_send_int (gnutls_session_t session, content_type_t type,
                           gnutls_handshake_description_t htype,
                           unsigned int epoch_rel, const void *data,
index 83d6282446c5cc82212c37682367939dea9200d2..879340c4be37156b4b19d17d813943bf32e113e6 100644 (file)
@@ -884,8 +884,16 @@ gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
   int gnutls_heartbeat_pong (gnutls_session_t session, unsigned int flags);
 
   void gnutls_record_set_timeout (gnutls_session_t session, unsigned int ms);
+
+  typedef struct {
+    size_t low;
+    size_t high;
+  } gnutls_range_st;
+
   ssize_t gnutls_record_send (gnutls_session_t session, const void *data,
                               size_t data_size);
+  ssize_t gnutls_range_send_message (gnutls_session_t session, const void *data,
+                                     size_t data_size, gnutls_range_st range);
   ssize_t gnutls_record_recv (gnutls_session_t session, void *data,
                               size_t data_size);
 #define gnutls_read gnutls_record_recv
@@ -895,13 +903,14 @@ gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
 
   void gnutls_session_enable_compatibility_mode (gnutls_session_t session);
 
-  void gnutls_record_disable_padding (gnutls_session_t session);
+  void gnutls_record_max_empty_records (gnutls_session_t session, const unsigned int i);
+  
+  int gnutls_range_can_use_length_hiding (gnutls_session_t session);
 
   int gnutls_record_get_direction (gnutls_session_t session);
 
   size_t gnutls_record_get_max_size (gnutls_session_t session);
   ssize_t gnutls_record_set_max_size (gnutls_session_t session, size_t size);
-  int gnutls_record_get_random_padding_status (gnutls_session_t session);
 
   size_t gnutls_record_check_pending (gnutls_session_t session);
 
index 065894cf26edc4f23b3e22eae1bc29b9a63a5380..85eb13284088c14b3c443eec6c36cc8da03b24d1 100644 (file)
@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (cli-args.c)
  *  
- *  It has been AutoGen-ed  November  9, 2012 at 05:12:10 PM by AutoGen 5.16
+ *  It has been AutoGen-ed  January 22, 2013 at 05:25:25 PM by AutoGen 5.15
  *  From the definitions    cli-args.def
  *  and the template file   options
  *
- * Generated from AutoOpts 36:4:11 templates.
+ * Generated from AutoOpts 36:3:11 templates.
  *
  *  AutoOpts is a copyrighted work.  This source file is not encumbered
  *  by AutoOpts licensing, but is provided under the licensing terms chosen
@@ -39,7 +39,6 @@
  *  with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __doxygen__
 #define OPTION_CODE_COMPILE 1
 #include "cli-args.h"
 #include <sys/types.h>
@@ -59,6 +58,7 @@ extern FILE * option_usage_fp;
 #define zCopyright      (gnutls_cli_opt_strs+0)
 #define zLicenseDescrip (gnutls_cli_opt_strs+281)
 
+extern tUsageProc optionUsage;
 
 #ifndef NULL
 #  define NULL 0
@@ -67,7 +67,7 @@ extern FILE * option_usage_fp;
 /*
  *  gnutls-cli option static const strings
  */
-static char const gnutls_cli_opt_strs[3786] =
+static char const gnutls_cli_opt_strs[3868] =
 /*     0 */ "gnutls-cli @VERSION@\n"
             "Copyright (C) 2000-2012 Free Software Foundation, all rights reserved.\n"
             "This is free software. It is licensed for use, modification and\n"
@@ -196,38 +196,41 @@ static char const gnutls_cli_opt_strs[3786] =
 /*  2762 */ "Don't abort program if server certificate can't be validated\0"
 /*  2823 */ "INSECURE\0"
 /*  2832 */ "insecure\0"
-/*  2841 */ "Benchmark individual ciphers\0"
-/*  2870 */ "BENCHMARK_CIPHERS\0"
-/*  2888 */ "benchmark-ciphers\0"
-/*  2906 */ "Benchmark individual software ciphers (no hw acceleration)\0"
-/*  2965 */ "BENCHMARK_SOFT_CIPHERS\0"
-/*  2988 */ "benchmark-soft-ciphers\0"
-/*  3011 */ "Benchmark TLS key exchange methods\0"
-/*  3046 */ "BENCHMARK_TLS_KX\0"
-/*  3063 */ "benchmark-tls-kx\0"
-/*  3080 */ "Benchmark TLS ciphers\0"
-/*  3102 */ "BENCHMARK_TLS_CIPHERS\0"
-/*  3124 */ "benchmark-tls-ciphers\0"
-/*  3146 */ "Print a list of the supported algorithms and modes\0"
-/*  3197 */ "LIST\0"
-/*  3202 */ "list\0"
-/*  3207 */ "Display extended usage information and exit\0"
-/*  3251 */ "help\0"
-/*  3256 */ "Extended usage information passed thru pager\0"
-/*  3301 */ "more-help\0"
-/*  3311 */ "Output version information and exit\0"
-/*  3347 */ "version\0"
-/*  3355 */ "GNUTLS_CLI\0"
-/*  3366 */ "gnutls-cli - GnuTLS client - Ver. @VERSION@\n"
+/*  2841 */ "When possible, use length-hiding padding to prevent traffic analysis\0"
+/*  2910 */ "RANGES\0"
+/*  2917 */ "ranges\0"
+/*  2924 */ "Benchmark individual ciphers\0"
+/*  2953 */ "BENCHMARK_CIPHERS\0"
+/*  2971 */ "benchmark-ciphers\0"
+/*  2989 */ "Benchmark individual software ciphers (no hw acceleration)\0"
+/*  3048 */ "BENCHMARK_SOFT_CIPHERS\0"
+/*  3071 */ "benchmark-soft-ciphers\0"
+/*  3094 */ "Benchmark TLS key exchange methods\0"
+/*  3129 */ "BENCHMARK_TLS_KX\0"
+/*  3146 */ "benchmark-tls-kx\0"
+/*  3163 */ "Benchmark TLS ciphers\0"
+/*  3185 */ "BENCHMARK_TLS_CIPHERS\0"
+/*  3207 */ "benchmark-tls-ciphers\0"
+/*  3229 */ "Print a list of the supported algorithms and modes\0"
+/*  3280 */ "LIST\0"
+/*  3285 */ "list\0"
+/*  3290 */ "Display extended usage information and exit\0"
+/*  3334 */ "help\0"
+/*  3339 */ "Extended usage information passed thru pager\0"
+/*  3384 */ "more-help\0"
+/*  3394 */ "Output version information and exit\0"
+/*  3430 */ "version\0"
+/*  3438 */ "GNUTLS_CLI\0"
+/*  3449 */ "gnutls-cli - GnuTLS client - Ver. @VERSION@\n"
             "USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostname]\n\0"
-/*  3479 */ "bug-gnutls@gnu.org\0"
-/*  3498 */ "\n\n\0"
-/*  3501 */ "\n"
-            "Simple client program to set up a TLS connection to some other computer.  It\n"
-            "sets up a TLS connection and forwards data from the standard input to the\n"
-            "secured socket and vice versa.\n\0"
-/*  3685 */ "gnutls-cli @VERSION@\0"
-/*  3706 */ "Usage: gnutls-cli [options] hostname\n"
+/*  3562 */ "bug-gnutls@gnu.org\0"
+/*  3581 */ "\n\n\0"
+/*  3584 */ "\n"
+            "Simple client program to set up a TLS connection to some other computer.\n"
+            "It sets up a TLS connection and forwards data from the standard input to\n"
+            "the secured socket and vice versa.\n\0"
+/*  3767 */ "gnutls-cli @VERSION@\0"
+/*  3788 */ "Usage: gnutls-cli [options] hostname\n"
             "gnutls-cli --help for usage instructions.\n";
 
 /*
@@ -555,54 +558,62 @@ static char const gnutls_cli_opt_strs[3786] =
 #define INSECURE_name      (gnutls_cli_opt_strs+2832)
 #define INSECURE_FLAGS     (OPTST_DISABLED)
 
+/*
+ *  ranges option description:
+ */
+#define RANGES_DESC      (gnutls_cli_opt_strs+2841)
+#define RANGES_NAME      (gnutls_cli_opt_strs+2910)
+#define RANGES_name      (gnutls_cli_opt_strs+2917)
+#define RANGES_FLAGS     (OPTST_DISABLED)
+
 /*
  *  benchmark-ciphers option description:
  */
-#define BENCHMARK_CIPHERS_DESC      (gnutls_cli_opt_strs+2841)
-#define BENCHMARK_CIPHERS_NAME      (gnutls_cli_opt_strs+2870)
-#define BENCHMARK_CIPHERS_name      (gnutls_cli_opt_strs+2888)
+#define BENCHMARK_CIPHERS_DESC      (gnutls_cli_opt_strs+2924)
+#define BENCHMARK_CIPHERS_NAME      (gnutls_cli_opt_strs+2953)
+#define BENCHMARK_CIPHERS_name      (gnutls_cli_opt_strs+2971)
 #define BENCHMARK_CIPHERS_FLAGS     (OPTST_DISABLED)
 
 /*
  *  benchmark-soft-ciphers option description:
  */
-#define BENCHMARK_SOFT_CIPHERS_DESC      (gnutls_cli_opt_strs+2906)
-#define BENCHMARK_SOFT_CIPHERS_NAME      (gnutls_cli_opt_strs+2965)
-#define BENCHMARK_SOFT_CIPHERS_name      (gnutls_cli_opt_strs+2988)
+#define BENCHMARK_SOFT_CIPHERS_DESC      (gnutls_cli_opt_strs+2989)
+#define BENCHMARK_SOFT_CIPHERS_NAME      (gnutls_cli_opt_strs+3048)
+#define BENCHMARK_SOFT_CIPHERS_name      (gnutls_cli_opt_strs+3071)
 #define BENCHMARK_SOFT_CIPHERS_FLAGS     (OPTST_DISABLED)
 
 /*
  *  benchmark-tls-kx option description:
  */
-#define BENCHMARK_TLS_KX_DESC      (gnutls_cli_opt_strs+3011)
-#define BENCHMARK_TLS_KX_NAME      (gnutls_cli_opt_strs+3046)
-#define BENCHMARK_TLS_KX_name      (gnutls_cli_opt_strs+3063)
+#define BENCHMARK_TLS_KX_DESC      (gnutls_cli_opt_strs+3094)
+#define BENCHMARK_TLS_KX_NAME      (gnutls_cli_opt_strs+3129)
+#define BENCHMARK_TLS_KX_name      (gnutls_cli_opt_strs+3146)
 #define BENCHMARK_TLS_KX_FLAGS     (OPTST_DISABLED)
 
 /*
  *  benchmark-tls-ciphers option description:
  */
-#define BENCHMARK_TLS_CIPHERS_DESC      (gnutls_cli_opt_strs+3080)
-#define BENCHMARK_TLS_CIPHERS_NAME      (gnutls_cli_opt_strs+3102)
-#define BENCHMARK_TLS_CIPHERS_name      (gnutls_cli_opt_strs+3124)
+#define BENCHMARK_TLS_CIPHERS_DESC      (gnutls_cli_opt_strs+3163)
+#define BENCHMARK_TLS_CIPHERS_NAME      (gnutls_cli_opt_strs+3185)
+#define BENCHMARK_TLS_CIPHERS_name      (gnutls_cli_opt_strs+3207)
 #define BENCHMARK_TLS_CIPHERS_FLAGS     (OPTST_DISABLED)
 
 /*
  *  list option description:
  */
-#define LIST_DESC      (gnutls_cli_opt_strs+3146)
-#define LIST_NAME      (gnutls_cli_opt_strs+3197)
-#define LIST_name      (gnutls_cli_opt_strs+3202)
+#define LIST_DESC      (gnutls_cli_opt_strs+3229)
+#define LIST_NAME      (gnutls_cli_opt_strs+3280)
+#define LIST_name      (gnutls_cli_opt_strs+3285)
 #define LIST_FLAGS     (OPTST_DISABLED)
 
 /*
  *  Help/More_Help/Version option descriptions:
  */
-#define HELP_DESC       (gnutls_cli_opt_strs+3207)
-#define HELP_name       (gnutls_cli_opt_strs+3251)
+#define HELP_DESC       (gnutls_cli_opt_strs+3290)
+#define HELP_name       (gnutls_cli_opt_strs+3334)
 #ifdef HAVE_WORKING_FORK
-#define MORE_HELP_DESC  (gnutls_cli_opt_strs+3256)
-#define MORE_HELP_name  (gnutls_cli_opt_strs+3301)
+#define MORE_HELP_DESC  (gnutls_cli_opt_strs+3339)
+#define MORE_HELP_name  (gnutls_cli_opt_strs+3384)
 #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
 #else
 #define MORE_HELP_DESC  NULL
@@ -615,8 +626,8 @@ static char const gnutls_cli_opt_strs[3786] =
 #  define VER_FLAGS     (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
                          OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
 #endif
-#define VER_DESC        (gnutls_cli_opt_strs+3311)
-#define VER_name        (gnutls_cli_opt_strs+3347)
+#define VER_DESC        (gnutls_cli_opt_strs+3394)
+#define VER_name        (gnutls_cli_opt_strs+3430)
 /*
  *  Declare option callback procedures
  */
@@ -630,11 +641,9 @@ static tOptProc
     doOptPgpkeyring,  doOptRecordsize,  doOptX509crlfile, doUsageOpt;
 #define VER_PROC        optionPrintVersion
 
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/**
- *  Define the gnutls-cli Option Descriptions.
- * This is an array of OPTION_CT entries, one for each
- * option that the gnutls-cli program responds to.
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Gnutls_Cli Option Descriptions.
  */
 static tOptDesc optDesc[OPTION_CT] = {
   {  /* entry idx, value */ 0, VALUE_OPT_DEBUG,
@@ -1081,8 +1090,20 @@ static tOptDesc optDesc[OPTION_CT] = {
      /* desc, NAME, name */ INSECURE_DESC, INSECURE_NAME, INSECURE_name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 37, VALUE_OPT_BENCHMARK_CIPHERS,
-     /* equiv idx, value */ 37, VALUE_OPT_BENCHMARK_CIPHERS,
+  {  /* entry idx, value */ 37, VALUE_OPT_RANGES,
+     /* equiv idx, value */ 37, VALUE_OPT_RANGES,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ RANGES_FLAGS, 0,
+     /* last opt argumnt */ { NULL }, /* --ranges */
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ RANGES_DESC, RANGES_NAME, RANGES_name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 38, VALUE_OPT_BENCHMARK_CIPHERS,
+     /* equiv idx, value */ 38, VALUE_OPT_BENCHMARK_CIPHERS,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ BENCHMARK_CIPHERS_FLAGS, 0,
@@ -1093,8 +1114,8 @@ static tOptDesc optDesc[OPTION_CT] = {
      /* desc, NAME, name */ BENCHMARK_CIPHERS_DESC, BENCHMARK_CIPHERS_NAME, BENCHMARK_CIPHERS_name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 38, VALUE_OPT_BENCHMARK_SOFT_CIPHERS,
-     /* equiv idx, value */ 38, VALUE_OPT_BENCHMARK_SOFT_CIPHERS,
+  {  /* entry idx, value */ 39, VALUE_OPT_BENCHMARK_SOFT_CIPHERS,
+     /* equiv idx, value */ 39, VALUE_OPT_BENCHMARK_SOFT_CIPHERS,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ BENCHMARK_SOFT_CIPHERS_FLAGS, 0,
@@ -1105,8 +1126,8 @@ static tOptDesc optDesc[OPTION_CT] = {
      /* desc, NAME, name */ BENCHMARK_SOFT_CIPHERS_DESC, BENCHMARK_SOFT_CIPHERS_NAME, BENCHMARK_SOFT_CIPHERS_name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 39, VALUE_OPT_BENCHMARK_TLS_KX,
-     /* equiv idx, value */ 39, VALUE_OPT_BENCHMARK_TLS_KX,
+  {  /* entry idx, value */ 40, VALUE_OPT_BENCHMARK_TLS_KX,
+     /* equiv idx, value */ 40, VALUE_OPT_BENCHMARK_TLS_KX,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ BENCHMARK_TLS_KX_FLAGS, 0,
@@ -1117,8 +1138,8 @@ static tOptDesc optDesc[OPTION_CT] = {
      /* desc, NAME, name */ BENCHMARK_TLS_KX_DESC, BENCHMARK_TLS_KX_NAME, BENCHMARK_TLS_KX_name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 40, VALUE_OPT_BENCHMARK_TLS_CIPHERS,
-     /* equiv idx, value */ 40, VALUE_OPT_BENCHMARK_TLS_CIPHERS,
+  {  /* entry idx, value */ 41, VALUE_OPT_BENCHMARK_TLS_CIPHERS,
+     /* equiv idx, value */ 41, VALUE_OPT_BENCHMARK_TLS_CIPHERS,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ BENCHMARK_TLS_CIPHERS_FLAGS, 0,
@@ -1129,8 +1150,8 @@ static tOptDesc optDesc[OPTION_CT] = {
      /* desc, NAME, name */ BENCHMARK_TLS_CIPHERS_DESC, BENCHMARK_TLS_CIPHERS_NAME, BENCHMARK_TLS_CIPHERS_name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 41, VALUE_OPT_LIST,
-     /* equiv idx, value */ 41, VALUE_OPT_LIST,
+  {  /* entry idx, value */ 42, VALUE_OPT_LIST,
+     /* equiv idx, value */ 42, VALUE_OPT_LIST,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ LIST_FLAGS, 0,
@@ -1183,17 +1204,17 @@ static tOptDesc optDesc[OPTION_CT] = {
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *
- *  Define the gnutls-cli Option Environment
+ *  Define the Gnutls_Cli Option Environment
  */
-#define zPROGNAME       (gnutls_cli_opt_strs+3355)
-#define zUsageTitle     (gnutls_cli_opt_strs+3366)
+#define zPROGNAME       (gnutls_cli_opt_strs+3438)
+#define zUsageTitle     (gnutls_cli_opt_strs+3449)
 #define zRcName         NULL
 #define apzHomeList     NULL
-#define zBugsAddr       (gnutls_cli_opt_strs+3479)
-#define zExplain        (gnutls_cli_opt_strs+3498)
-#define zDetail         (gnutls_cli_opt_strs+3501)
-#define zFullVersion    (gnutls_cli_opt_strs+3685)
-/* extracted from optcode.tlib near line 350 */
+#define zBugsAddr       (gnutls_cli_opt_strs+3562)
+#define zExplain        (gnutls_cli_opt_strs+3581)
+#define zDetail         (gnutls_cli_opt_strs+3584)
+#define zFullVersion    (gnutls_cli_opt_strs+3767)
+/* extracted from optcode.tlib near line 349 */
 
 #if defined(ENABLE_NLS)
 # define OPTPROC_BASE OPTPROC_TRANSLATE | OPTPROC_NXLAT_OPT
@@ -1206,27 +1227,22 @@ static tOptDesc optDesc[OPTION_CT] = {
 
 #define gnutls_cli_full_usage (NULL)
 
-#define gnutls_cli_short_usage (gnutls_cli_opt_strs+3706)
-
-#endif /* not defined __doxygen__ */
+#define gnutls_cli_short_usage (gnutls_cli_opt_strs+3788)
 
 /*
  *  Create the static procedure(s) declared above.
  */
 /**
- * The callout function that invokes the optionUsage function.
+ * The callout function that invokes the USAGE() macro.
  *
  * @param pOptions the AutoOpts option description structure
  * @param pOptDesc the descriptor for the "help" (usage) option.
- * @noreturn
  */
 static void
 doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
 {
-    optionUsage(&gnutls_cliOptions, GNUTLS_CLI_EXIT_SUCCESS);
-    /* NOTREACHED */
-    (void)pOptDesc;
     (void)pOptions;
+    USAGE(GNUTLS_CLI_EXIT_SUCCESS);
 }
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -1420,19 +1436,12 @@ doOptPgpcertfile(tOptions* pOptions, tOptDesc* pOptDesc)
 
     optionFileCheck(pOptions, pOptDesc, type, mode);
 }
-/* extracted from optmain.tlib near line 1113 */
+/* extracted from optmain.tlib near line 1093 */
 
-/**
- * The directory containing the data associated with gnutls-cli.
- */
 #ifndef  PKGDATADIR
 # define PKGDATADIR ""
 #endif
 
-/**
- * Information about the person or institution that packaged gnutls-cli
- * for the current distribution.
- */
 #ifndef  WITH_PACKAGER
 # define gnutls_cli_packager_info NULL
 #else
@@ -1448,13 +1457,7 @@ static char const gnutls_cli_packager_info[] =
 # endif
     "\n";
 #endif
-#ifndef __doxygen__
 
-#endif /* __doxygen__ */
-/**
- * The option definitions for gnutls-cli.  The one structure that
- * binds them all.
- */
 tOptions gnutls_cliOptions = {
     OPTIONS_STRUCT_VERSION,
     0, NULL,                    /* original argc + argv    */
@@ -1484,7 +1487,7 @@ tOptions gnutls_cliOptions = {
       NO_EQUIVALENT, /* '-#' option index */
       NO_EQUIVALENT /* index of default opt */
     },
-    45 /* full option count */, 42 /* user option count */,
+    46 /* full option count */, 43 /* user option count */,
     gnutls_cli_full_usage, gnutls_cli_short_usage,
     NULL, NULL,
     PKGDATADIR, gnutls_cli_packager_info
@@ -1500,16 +1503,7 @@ tOptions gnutls_cliOptions = {
 static char* AO_gettext(char const* pz);
 static void  coerce_it(void** s);
 
-/**
- * AutoGen specific wrapper function for gettext.
- * It relies on the macro _() to convert from English to the target
- * language, then strdup-duplicates the result string.
- *
- * @param[in] pz the input text used as a lookup key.
- * @returns the translated text (if there is one),
- *   or the original text (if not).
- */
-static char *
+static char*
 AO_gettext(char const* pz)
 {
     char* pzRes;
@@ -1529,9 +1523,8 @@ AO_gettext(char const* pz)
 static void coerce_it(void** s) { *s = AO_gettext(*s);
 }
 
-/**
- * Translate all the translatable strings in the gnutls_cliOptions
- * structure defined above.  This is done only once.
+/*
+ *  This invokes the translation code (e.g. gettext(3)).
  */
 static void
 translate_option_strings(void)
index 052cd59950ea6d825624a1e87f5e44eb1ae18750..2b3e07e7ce2e925e4de1beb2c35b1175bf79288c 100644 (file)
@@ -271,6 +271,12 @@ flag = {
     doc      = "";
 };
 
+flag = {
+    name      = ranges;
+    descrip   = "When possible, use length-hiding padding to prevent traffic analysis";
+    doc      = "";
+};
+
 flag = {
     name      = benchmark-ciphers;
     descrip   = "Benchmark individual ciphers";
index 576f11e3ba10a60bbd53bc779dfcaf014d83f84c..684e3972ba8f15a4a8af9761d759d9c679f5ebbf 100644 (file)
@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (cli-args.h)
  *  
- *  It has been AutoGen-ed  November  9, 2012 at 05:12:09 PM by AutoGen 5.16
+ *  It has been AutoGen-ed  January 22, 2013 at 05:25:25 PM by AutoGen 5.15
  *  From the definitions    cli-args.def
  *  and the template file   options
  *
- * Generated from AutoOpts 36:4:11 templates.
+ * Generated from AutoOpts 36:3:11 templates.
  *
  *  AutoOpts is a copyrighted work.  This header file is not encumbered
  *  by AutoOpts licensing, but is provided under the licensing terms chosen
@@ -56,7 +56,7 @@
  *  tolerable version is at least as old as what was current when the header
  *  template was released.
  */
-#define AO_TEMPLATE_VERSION 147460
+#define AO_TEMPLATE_VERSION 147459
 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
 # error option template version mismatches autoopts/options.h header
@@ -104,17 +104,18 @@ typedef enum {
     INDEX_OPT_PSKKEY                  = 34,
     INDEX_OPT_PORT                    = 35,
     INDEX_OPT_INSECURE                = 36,
-    INDEX_OPT_BENCHMARK_CIPHERS       = 37,
-    INDEX_OPT_BENCHMARK_SOFT_CIPHERS  = 38,
-    INDEX_OPT_BENCHMARK_TLS_KX        = 39,
-    INDEX_OPT_BENCHMARK_TLS_CIPHERS   = 40,
-    INDEX_OPT_LIST                    = 41,
-    INDEX_OPT_VERSION                 = 42,
-    INDEX_OPT_HELP                    = 43,
-    INDEX_OPT_MORE_HELP               = 44
+    INDEX_OPT_RANGES                  = 37,
+    INDEX_OPT_BENCHMARK_CIPHERS       = 38,
+    INDEX_OPT_BENCHMARK_SOFT_CIPHERS  = 39,
+    INDEX_OPT_BENCHMARK_TLS_KX        = 40,
+    INDEX_OPT_BENCHMARK_TLS_CIPHERS   = 41,
+    INDEX_OPT_LIST                    = 42,
+    INDEX_OPT_VERSION                 = 43,
+    INDEX_OPT_HELP                    = 44,
+    INDEX_OPT_MORE_HELP               = 45
 } teOptIndex;
 
-#define OPTION_CT    45
+#define OPTION_CT    46
 #define GNUTLS_CLI_VERSION       "@VERSION@"
 #define GNUTLS_CLI_FULL_VERSION  "gnutls-cli @VERSION@"
 
@@ -145,8 +146,7 @@ typedef enum {
  */
 typedef enum {
     GNUTLS_CLI_EXIT_SUCCESS = 0,
-    GNUTLS_CLI_EXIT_FAILURE = 1,
-    GNUTLS_CLI_EXIT_LIBOPTS_FAILURE = 70
+    GNUTLS_CLI_EXIT_FAILURE = 1
 } gnutls_cli_exit_code_t;
 /* * * * * *
  *
@@ -197,10 +197,11 @@ typedef enum {
 #define VALUE_OPT_PSKKEY         130
 #define VALUE_OPT_PORT           'p'
 #define VALUE_OPT_INSECURE       132
-#define VALUE_OPT_BENCHMARK_CIPHERS 133
-#define VALUE_OPT_BENCHMARK_SOFT_CIPHERS 134
-#define VALUE_OPT_BENCHMARK_TLS_KX 135
-#define VALUE_OPT_BENCHMARK_TLS_CIPHERS 136
+#define VALUE_OPT_RANGES         133
+#define VALUE_OPT_BENCHMARK_CIPHERS 134
+#define VALUE_OPT_BENCHMARK_SOFT_CIPHERS 135
+#define VALUE_OPT_BENCHMARK_TLS_KX 136
+#define VALUE_OPT_BENCHMARK_TLS_CIPHERS 137
 #define VALUE_OPT_LIST           'l'
 #define VALUE_OPT_HELP          'h'
 #define VALUE_OPT_MORE_HELP     '!'
@@ -215,7 +216,7 @@ typedef enum {
                 gnutls_cliOptions.pzCurOpt  = NULL)
 #define START_OPT       RESTART_OPT(1)
 #define USAGE(c)        (*gnutls_cliOptions.pUsageProc)(&gnutls_cliOptions, c)
-/* extracted from opthead.tlib near line 484 */
+/* extracted from opthead.tlib near line 469 */
 
 #ifdef  __cplusplus
 extern "C" {
index 142c8831d232e6c18ec83646a8376ebd130ed6a3..deacb6b41828949434dcc2abdf79bf403dcd5821 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -68,7 +68,7 @@
 #define MAX_BUF 4096
 
 /* global stuff here */
-int resume, starttls, insecure, rehandshake, udp, mtu;
+int resume, starttls, insecure, ranges, rehandshake, udp, mtu;
 const char *hostname = NULL;
 const char *service = NULL;
 int record_max_size;
@@ -1030,8 +1030,14 @@ after_handshake:
                   bytes++;
                 }
             }
-
-          ret = socket_send (&hd, buffer, bytes);
+          if (ranges && gnutls_range_can_use_length_hiding(hd.session)) {
+                         gnutls_range_st range;
+                         range.low = 0;
+                         range.high = MAX_BUF;
+                         ret = socket_send_range (&hd, buffer, bytes, &range);
+          } else {
+                 ret = socket_send(&hd, buffer, bytes);
+          }
 
           if (ret > 0)
             {
@@ -1129,6 +1135,7 @@ const char* rest = NULL;
   resume = HAVE_OPT(RESUME);
   rehandshake = HAVE_OPT(REHANDSHAKE);
   insecure = HAVE_OPT(INSECURE);
+  ranges   = HAVE_OPT(RANGES);
 
   udp = HAVE_OPT(UDP);
   mtu = OPT_VALUE_MTU;
index 20c366f788cd32bd2d28c48fec13774f3c7419ee..a0c8d64505934a8041d84d5f657aeae399009152 100644 (file)
@@ -72,13 +72,24 @@ socket_recv (const socket_st * socket, void *buffer, int buffer_size)
 
 ssize_t
 socket_send (const socket_st * socket, const void *buffer, int buffer_size)
+{
+  return socket_send_range(socket, buffer, buffer_size, NULL);
+}
+
+
+ssize_t
+socket_send_range (const socket_st * socket, const void *buffer, int buffer_size, gnutls_range_st *range)
 {
   int ret;
 
   if (socket->secure)
     do
       {
-        ret = gnutls_record_send (socket->session, buffer, buffer_size);
+       if (range == NULL) {
+               ret = gnutls_record_send (socket->session, buffer, buffer_size);
+       } else {
+               ret = gnutls_range_send_message(socket->session, buffer, buffer_size, *range);
+       }
       }
     while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
   else
index 9f98faf458bdfd4771ced4db15ab565904f6024e..ac30d315151f41ec7aefbb809e929b83b7670b20 100644 (file)
@@ -15,6 +15,8 @@ typedef struct
 ssize_t socket_recv (const socket_st * socket, void *buffer, int buffer_size);
 ssize_t socket_send (const socket_st * socket, const void *buffer,
                      int buffer_size);
+ssize_t socket_send_range(const socket_st * socket, const void *buffer,
+                                         int buffer_size, gnutls_range_st *range);
 void socket_open (socket_st * hd, const char *hostname, const char *service, int udp);
 void socket_bye (socket_st * socket);
 
index 48cd5ebfb731528e2e0c2c600cff38eacc71dcf8..8843f379329ef647f5ff54dae62275bc35367717 100644 (file)
@@ -397,9 +397,9 @@ static void start (const char* prio)
 #define AES_CBC_SHA256 "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+RSA:+AES-128-CBC:+AES-256-CBC:+SHA256:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL"
 #define AES_GCM "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+RSA:+AES-128-GCM:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL"
 
-#define NEW_AES_CBC "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL:%RANDOM_PADDING"
-#define NEW_AES_CBC_SHA256 "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+RSA:+AES-128-CBC:+AES-256-CBC:+SHA256:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL:%RANDOM_PADDING"
-#define NEW_AES_GCM "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+RSA:+AES-128-GCM:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL:%RANDOM_PADDING"
+#define NEW_AES_CBC "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL:%NEW_PADDING"
+#define NEW_AES_CBC_SHA256 "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+RSA:+AES-128-CBC:+AES-256-CBC:+SHA256:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL:%NEW_PADDING"
+#define NEW_AES_GCM "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+RSA:+AES-128-GCM:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL:%NEW_PADDING"
 
 static void ch_handler(int sig)
 {