~ubuntu-branches/ubuntu/lucid/openssl/lucid-proposed

« back to all changes in this revision

Viewing changes to crypto/dsa/dsa_lib.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2009-06-13 18:15:46 UTC
  • mto: (11.1.5 squeeze)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20090613181546-vbfntai3b009dl1u
Tags: upstream-0.9.8k
ImportĀ upstreamĀ versionĀ 0.9.8k

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
 
77
77
void DSA_set_default_method(const DSA_METHOD *meth)
78
78
        {
 
79
#ifdef OPENSSL_FIPS
 
80
        if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD))
 
81
                {
 
82
                DSAerr(DSA_F_DSA_SET_DEFAULT_METHOD, DSA_R_NON_FIPS_METHOD);
 
83
                return;
 
84
                }
 
85
#endif
 
86
                
79
87
        default_DSA_method = meth;
80
88
        }
81
89
 
96
104
        /* NB: The caller is specifically setting a method, so it's not up to us
97
105
         * to deal with which ENGINE it comes from. */
98
106
        const DSA_METHOD *mtmp;
 
107
#ifdef OPENSSL_FIPS
 
108
        if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD))
 
109
                {
 
110
                DSAerr(DSA_F_DSA_SET_METHOD, DSA_R_NON_FIPS_METHOD);
 
111
                return 0;
 
112
                }
 
113
#endif
99
114
        mtmp = dsa->meth;
100
115
        if (mtmp->finish) mtmp->finish(dsa);
101
116
#ifndef OPENSSL_NO_ENGINE
147
162
                        }
148
163
                }
149
164
#endif
 
165
#ifdef OPENSSL_FIPS
 
166
        if (FIPS_mode() && !(ret->meth->flags & DSA_FLAG_FIPS_METHOD))
 
167
                {
 
168
                DSAerr(DSA_F_DSA_NEW_METHOD, DSA_R_NON_FIPS_METHOD);
 
169
#ifndef OPENSSL_NO_ENGINE
 
170
                if (ret->engine)
 
171
                        ENGINE_finish(ret->engine);
 
172
#endif
 
173
                OPENSSL_free(ret);
 
174
                return NULL;
 
175
                }
 
176
#endif
150
177
 
151
178
        ret->pad=0;
152
179
        ret->version=0;
233
260
        return ((i > 1) ? 1 : 0);
234
261
        }
235
262
 
236
 
int DSA_size(const DSA *r)
237
 
        {
238
 
        int ret,i;
239
 
        ASN1_INTEGER bs;
240
 
        unsigned char buf[4];   /* 4 bytes looks really small.
241
 
                                   However, i2d_ASN1_INTEGER() will not look
242
 
                                   beyond the first byte, as long as the second
243
 
                                   parameter is NULL. */
244
 
 
245
 
        i=BN_num_bits(r->q);
246
 
        bs.length=(i+7)/8;
247
 
        bs.data=buf;
248
 
        bs.type=V_ASN1_INTEGER;
249
 
        /* If the top bit is set the asn1 encoding is 1 larger. */
250
 
        buf[0]=0xff;    
251
 
 
252
 
        i=i2d_ASN1_INTEGER(&bs,NULL);
253
 
        i+=i; /* r and s */
254
 
        ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
255
 
        return(ret);
256
 
        }
257
 
 
258
263
int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
259
264
             CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
260
265
        {