~ubuntu-branches/ubuntu/karmic/nss/karmic-updates

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/softoken/pkcs11c.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Fabien Tassin, Alexander Sack
  • Date: 2009-01-11 15:06:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090111150617-iz4lw05qgy2odorl
Tags: 3.12.2~rc1-0ubuntu1
* New upstream snapshot: 3.12.2 RC1

[ Fabien Tassin <fta@ubuntu.com> ]
* Remove patch applied upstream:
  - drop debian/patches/80_security_tools.patch
  - update debian/patches/series
* Update diverged patches:
  - update debian/patches/38_kbsd.patch
  - update debian/patches/38_mips64_build.patch
* Add new symbols to symbols file
  - update debian/libnss3-1d.symbols

[ Alexander Sack <asac@ubuntu.com> ]
* disable soname patch to become binary compatible with upstream
  - update debian/patches/series
* flip links: libnss3.so <- libnss3.so.1d (before: libnss3.so ->
  libnss3.so.1d); same link flipping was done for all other previously
  soname patched libs: libnssutil3.so, libsmime3.so.1d, libssl3.so.1d
  - update debian/libnss3-1d.links
  - update debian/libnss3-1d.symbols
* properly transition links in preinst and postrm; also cover abort-
  cases in the other maintainer scripts
  - add debian/libnss3-1d.postinst
  - add debian/libnss3-1d.postrm
  - add debian/libnss3-1d.preinst
  - add debian/libnss3-1d.prerm
* remove hack from debian/rules that debian uses to recreate
  libsoftokn3.so with a versioned SONAME
  - update debian/rules
* install the unversioned .so binaries
  - update debian/rules
* only install the 4 main libraries into /usr/lib; all the others
  go to pkglibdir
  - update debian/rules
* higher bar for libnspr4 Build-Depend to >= 4.7.3~, which is
  the version where the soname droppage is going to happen
  - update debian/control
* explitily pass libraries to be used for dpkg-gensymbols run of
  dh_makeshlibs
  - update debian/rules
* fix lintian complain about no-shlibs-control-file
  - update debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
#include "secasn1.h"
70
70
#include "secerr.h"
71
71
 
72
 
#include "ssl3prot.h"   /* for SSL3_RANDOM_LENGTH */
73
72
#include "prprf.h"
74
73
 
75
74
#define __PASTE(x,y)    x##y
88
87
 
89
88
#include "pkcs11f.h"
90
89
 
 
90
typedef struct {
 
91
    uint8 client_version[2];
 
92
    uint8 random[46];
 
93
} SSL3RSAPreMasterSecret;
 
94
 
91
95
static void sftk_Null(void *data, PRBool freeit)
92
96
{
93
97
    return;
152
156
    DES_DestroyContext(descx,PR_TRUE);
153
157
    if (rv != SECSuccess) return CKR_DEVICE_ERROR;
154
158
 
155
 
    /* xor source with des, zero the parity bits and depricate the key*/
 
159
    /* xor source with des, zero the parity bits and deprecate the key*/
156
160
    for (i=0; i < 8; i++) {
157
161
        if (i & 1) {
158
162
            enc_src[i] = (enc_src[i] ^ enc_dest[i]) & 0xfe;
242
246
 */
243
247
 
244
248
 
 
249
/*
 
250
 * map SEC_ERROR_xxx to CKR_xxx.
 
251
 */
 
252
static CK_RV
 
253
sftk_MapCryptError(int error)
 
254
{
 
255
    switch (error) {
 
256
        case SEC_ERROR_INVALID_ARGS:
 
257
            return CKR_ARGUMENTS_BAD;
 
258
        case SEC_ERROR_INPUT_LEN:
 
259
            return CKR_DATA_LEN_RANGE;
 
260
        case SEC_ERROR_OUTPUT_LEN:
 
261
            return CKR_BUFFER_TOO_SMALL;
 
262
    }
 
263
    return CKR_DEVICE_ERROR;
 
264
}
 
265
 
245
266
/* 
246
267
 * return a context based on the SFTKContext type.
247
268
 */
797
818
            rv = (*context->update)(context->cipherInfo, pEncryptedPart, 
798
819
                &padoutlen, context->blockSize, context->padBuf,
799
820
                                                        context->blockSize);
800
 
            if (rv != SECSuccess) return CKR_DEVICE_ERROR;
 
821
            if (rv != SECSuccess) {
 
822
                return sftk_MapCryptError(PORT_GetError());
 
823
            }
801
824
            pEncryptedPart += padoutlen;
802
825
            maxout -= padoutlen;
803
826
        }
821
844
    rv = (*context->update)(context->cipherInfo,pEncryptedPart, 
822
845
                                        &outlen, maxout, pPart, ulPartLen);
823
846
    *pulEncryptedPartLen = (CK_ULONG) (outlen + padoutlen);
824
 
    return (rv == SECSuccess) ? CKR_OK : CKR_DEVICE_ERROR;
 
847
    if (rv != SECSuccess) {
 
848
        return sftk_MapCryptError(PORT_GetError());
 
849
    }
 
850
    return CKR_OK;
825
851
}
826
852
 
827
853
 
2677
2703
 */
2678
2704
static CK_RV
2679
2705
nsc_pbe_key_gen(NSSPKCS5PBEParameter *pkcs5_pbe, CK_MECHANISM_PTR pMechanism,
2680
 
                        char *buf, CK_ULONG *key_length, PRBool faulty3DES)
 
2706
                        void *buf, CK_ULONG *key_length, PRBool faulty3DES)
2681
2707
{
2682
2708
    SECItem *pbe_key = NULL, iv, pwitem;
2683
2709
    CK_PBE_PARAMS *pbe_params = NULL;
3017
3043
    CK_BBOOL cktrue = CK_TRUE;
3018
3044
    int i;
3019
3045
    SFTKSlot *slot = sftk_SlotFromSessionHandle(hSession);
3020
 
    char buf[MAX_KEY_LEN];
 
3046
    unsigned char buf[MAX_KEY_LEN];
3021
3047
    enum {nsc_pbe, nsc_ssl, nsc_bulk, nsc_param} key_gen_type;
3022
3048
    NSSPKCS5PBEParameter *pbe_param;
3023
3049
    SSL3RSAPreMasterSecret *rsa_pms;
3163
3189
    case nsc_bulk:
3164
3190
        /* get the key, check for weak keys and repeat if found */
3165
3191
        do {
3166
 
            crv = NSC_GenerateRandom(0, (unsigned char *)buf, key_length);
3167
 
        } while (crv == CKR_OK && checkWeak && 
3168
 
                        sftk_IsWeakKey((unsigned char *)buf,key_type));
 
3192
            crv = NSC_GenerateRandom(0, buf, key_length);
 
3193
        } while (crv == CKR_OK && checkWeak && sftk_IsWeakKey(buf,key_type));
3169
3194
        break;
3170
3195
    case nsc_param:
3171
3196
        /* generate parameters */
4851
4876
    "IIIIIIIII" };
4852
4877
#define SSL3_PMS_LENGTH 48
4853
4878
#define SSL3_MASTER_SECRET_LENGTH 48
 
4879
#define SSL3_RANDOM_LENGTH 32
4854
4880
 
4855
4881
 
4856
4882
/* NSC_DeriveKey derives a key from a base key, creating a new key object. */