~ubuntu-branches/ubuntu/quantal/aria2/quantal

« back to all changes in this revision

Viewing changes to src/LibsslDHKeyExchange.h

  • Committer: Bazaar Package Importer
  • Author(s): Kartik Mistry
  • Date: 2010-11-24 12:26:31 UTC
  • mfrom: (1.6.1 upstream) (2.3.8 experimental)
  • Revision ID: james.westby@ubuntu.com-20101124122631-upujekj1ek94h3x2
Tags: 1.10.6-1
* New upstream release:
  + Fixed FTBFS on alpha arch (Closes: #590257)
  + Added IPv6 support (Closes: #448390)
* debian/patches/ftbfs_kfreebsd.diff:
  + Dropped, merged upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 * files in the program, then also delete it here.
33
33
 */
34
34
/* copyright --> */
35
 
#ifndef _D_LIBSSL_DH_KEY_EXCHANGE_H_
36
 
#define _D_LIBSSL_DH_KEY_EXCHANGE_H_
 
35
#ifndef D_LIBSSL_DH_KEY_EXCHANGE_H
 
36
#define D_LIBSSL_DH_KEY_EXCHANGE_H
37
37
 
38
38
#include "common.h"
39
39
#include "DlAbortEx.h"
124
124
  {
125
125
    if(outLength < keyLength_) {
126
126
      throw DL_ABORT_EX
127
 
        (StringFormat("Insufficient buffer for public key. expect:%u, actual:%u",
128
 
                      keyLength_, outLength).str());
 
127
        (StringFormat
 
128
         ("Insufficient buffer for public key. expect:%lu, actual:%lu",
 
129
          static_cast<unsigned long>(keyLength_),
 
130
          static_cast<unsigned long>(outLength)).str());
129
131
    }
130
132
    memset(out, 0, outLength);
131
133
    size_t publicKeyBytes = BN_num_bytes(publicKey_);
133
135
    size_t nwritten = BN_bn2bin(publicKey_, out+offset);
134
136
    if(nwritten != publicKeyBytes) {
135
137
      throw DL_ABORT_EX
136
 
        (StringFormat("BN_bn2bin in DHKeyExchange::getPublicKey, %u bytes written, but %u bytes expected.", nwritten, publicKeyBytes).str());
 
138
        (StringFormat
 
139
         ("BN_bn2bin in DHKeyExchange::getPublicKey, %lu bytes written,"
 
140
          " but %lu bytes expected.",
 
141
          static_cast<unsigned long>(nwritten),
 
142
          static_cast<unsigned long>(publicKeyBytes)).str());
137
143
    }
138
144
    return nwritten;
139
145
  }
151
157
  {
152
158
    if(outLength < keyLength_) {
153
159
      throw DL_ABORT_EX
154
 
        (StringFormat("Insufficient buffer for secret. expect:%u, actual:%u",
155
 
                      keyLength_, outLength).str());
 
160
        (StringFormat("Insufficient buffer for secret. expect:%lu, actual:%lu",
 
161
                      static_cast<unsigned long>(keyLength_),
 
162
                      static_cast<unsigned long>(outLength)).str());
156
163
    }
157
164
 
158
165
 
172
179
    BN_free(secret);
173
180
    if(nwritten != secretBytes) {
174
181
      throw DL_ABORT_EX
175
 
        (StringFormat("BN_bn2bin in DHKeyExchange::getPublicKey, %u bytes written, but %u bytes expected.", nwritten, secretBytes).str());
 
182
        (StringFormat
 
183
         ("BN_bn2bin in DHKeyExchange::getPublicKey, %lu bytes written,"
 
184
          " but %lu bytes expected.",
 
185
          static_cast<unsigned long>(nwritten),
 
186
          static_cast<unsigned long>(secretBytes)).str());
176
187
    }
177
188
    return nwritten;
178
189
  }
180
191
 
181
192
} // namespace aria2
182
193
 
183
 
#endif // _D_LIBSSL_DH_KEY_EXCHANGE_H_
 
194
#endif // D_LIBSSL_DH_KEY_EXCHANGE_H