~ubuntu-branches/ubuntu/trusty/globus-gssapi-gsi/trusty

« back to all changes in this revision

Viewing changes to library/sc_rsa_eay.patch

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2011-12-27 15:18:29 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20111227151829-wtxfg8n50mup50fo
Tags: 10.2-1
* Update to Globus Toolkit 5.2.0
* Make doc package architecture independent

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
*** /afs/anl.gov/appl/SSLeay-0.9.0/build/src/crypto/rsa/rsa_eay.c       Thu Apr  9 06:59:29 1998
2
 
--- src/sc_rsa_eay.c    Fri Oct 30 10:09:27 1998
3
 
***************
4
 
*** 62,67 ****
5
 
--- 62,70 ----
6
 
  #include "rsa.h"
7
 
  #include "rand.h"
8
 
  
9
 
+ #include "scutils.h"
10
 
+    
11
 
12
 
  #ifndef NOPROTO
13
 
  static int RSA_eay_public_encrypt(int flen, unsigned char *from,
14
 
                unsigned char *to, RSA *rsa,int padding);
15
 
***************
16
 
*** 85,91 ****
17
 
  #endif
18
 
  
19
 
  static RSA_METHOD rsa_pkcs1_eay_meth={
20
 
!       "Eric Young's PKCS#1 RSA",
21
 
        RSA_eay_public_encrypt,
22
 
        RSA_eay_public_decrypt,
23
 
        RSA_eay_private_encrypt,
24
 
--- 88,94 ----
25
 
  #endif
26
 
  
27
 
  static RSA_METHOD rsa_pkcs1_eay_meth={
28
 
!       "DEE Modified for use with PKCS#11, Eric Young's PKCS#1 RSA",
29
 
        RSA_eay_public_encrypt,
30
 
        RSA_eay_public_decrypt,
31
 
        RSA_eay_private_encrypt,
32
 
***************
33
 
*** 98,104 ****
34
 
        NULL,
35
 
        };
36
 
  
37
 
! RSA_METHOD *RSA_PKCS1_SSLeay()
38
 
        {
39
 
        return(&rsa_pkcs1_eay_meth);
40
 
        }
41
 
--- 101,107 ----
42
 
        NULL,
43
 
        };
44
 
  
45
 
! RSA_METHOD *sc_RSA_PKCS1_SSLeay()
46
 
        {
47
 
        return(&rsa_pkcs1_eay_meth);
48
 
        }
49
 
***************
50
 
*** 181,191 ****
51
 
--- 184,251 ----
52
 
  RSA *rsa;
53
 
  int padding;
54
 
        {
55
 
+ #if 0
56
 
        BIGNUM *f=NULL,*ret=NULL;
57
 
        int i,j,k,num=0,r= -1;
58
 
        unsigned char *buf=NULL;
59
 
        BN_CTX *ctx=NULL;
60
 
+ #endif
61
 
62
 
+       CK_ULONG ulsiglen;
63
 
+       CK_MECHANISM_PTR pMech = NULL;
64
 
+       CK_MECHANISM m_rsa_pkcs = {CKM_RSA_PKCS, 0,0};
65
 
+         CK_MECHANISM m_rsa_raw = {CKM_RSA_X_509, 0,0};
66
 
+       CK_RV ck_status;
67
 
+       CK_SESSION_HANDLE hSession;
68
 
+       CK_OBJECT_HANDLE hObject;
69
 
70
 
+       hSession = (CK_SESSION_HANDLE )RSA_get_ex_data(rsa,SC_RSA_EX_DATA_INDEX_SESSION);
71
 
+       hObject = (CK_OBJECT_HANDLE) RSA_get_ex_data(rsa,SC_RSA_EX_DATA_INDEX_OBJECT);
72
 
73
 
+ #ifdef DEBUG2
74
 
+       fprintf(stderr,"RSA_dee_private_encrypt\n");
75
 
+       fprintf(stderr,"hSession=%ld hObject=%ld\n", hSession, hObject);
76
 
+ #endif
77
 
78
 
+       switch (padding) {
79
 
+               case RSA_PKCS1_PADDING:
80
 
+                       pMech = &m_rsa_pkcs;
81
 
+                       break;
82
 
+               case RSA_NO_PADDING:
83
 
+                       pMech = &m_rsa_raw;
84
 
+                       break;
85
 
+               case RSA_SSLV23_PADDING:
86
 
+               default:
87
 
+                       RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,RSA_R_UNKNOWN_PADDING_TYPE);
88
 
+       }
89
 
+       if (pMech == NULL) {
90
 
+               return 0; 
91
 
+       }
92
 
+      
93
 
+ #ifdef DEBUG
94
 
+       fprintf(stderr,"Signing Proxy Certificate on Smart Card...\n");
95
 
+ #endif
96
 
  
97
 
+       ck_status = C_SignInit(hSession, pMech, hObject);
98
 
+       if (ck_status != CKR_OK) {
99
 
+                 SCerr(SCERR_F_RSA_ENCRYPT,SCERR_R_SIGNINIT);
100
 
+               ERR_add_error_data(1,sc_ERR_code(ck_status));
101
 
+               return 0;
102
 
+       }
103
 
+       ck_status = C_Sign(hSession,
104
 
+               from, flen, to, &ulsiglen);
105
 
+       if (ck_status != CKR_OK) {
106
 
+                 SCerr(SCERR_F_RSA_ENCRYPT,SCERR_R_SIGN);
107
 
+               ERR_add_error_data(1,sc_ERR_code(ck_status));
108
 
+               return 0;
109
 
+       }  
110
 
+       
111
 
+ #ifdef DEBUG
112
 
+       fprintf(stderr,"Signed\n");
113
 
+ #endif
114
 
115
 
+       return ulsiglen;        
116
 
+ #if 0
117
 
        if ((ctx=BN_CTX_new()) == NULL) goto err;
118
 
        num=BN_num_bytes(rsa->n);
119
 
        if ((buf=(unsigned char *)Malloc(num)) == NULL)
120
 
***************
121
 
*** 249,254 ****
122
 
--- 309,315 ----
123
 
                Free(buf);
124
 
                }
125
 
        return(r);
126
 
+ #endif
127
 
        }
128
 
  
129
 
  static int RSA_eay_private_decrypt(flen, from, to, rsa,padding)
130
 
***************
131
 
*** 258,274 ****
132
 
--- 319,395 ----
133
 
  RSA *rsa;
134
 
  int padding;
135
 
        {
136
 
+ #if 0
137
 
        BIGNUM *f=NULL,*ret=NULL;
138
 
        int j,num=0,r= -1;
139
 
        unsigned char *p;
140
 
        unsigned char *buf=NULL;
141
 
        BN_CTX *ctx=NULL;
142
 
+ #endif
143
 
  
144
 
+       CK_ULONG ulsiglen;
145
 
+       CK_MECHANISM_PTR pMech = NULL;
146
 
+       CK_MECHANISM m_rsa_pkcs = {CKM_RSA_PKCS, 0,0};
147
 
+         CK_MECHANISM m_rsa_raw = {CKM_RSA_X_509, 0,0};
148
 
+       CK_RV ck_status;
149
 
+       CK_SESSION_HANDLE hSession;
150
 
+       CK_OBJECT_HANDLE hObject;
151
 
152
 
+       hSession = (CK_SESSION_HANDLE )RSA_get_ex_data(rsa,SC_RSA_EX_DATA_INDEX_SESSION);
153
 
+       hObject = (CK_OBJECT_HANDLE) RSA_get_ex_data(rsa,SC_RSA_EX_DATA_INDEX_OBJECT);
154
 
155
 
+ #ifdef DEBUG
156
 
157
 
+       /* DEE - Not realy sure where this is used, of if the correct PKCS11 module is
158
 
+        * being called. It looks. like the SignRecover is equivelent to what is
159
 
+        * called the private_decrypt
160
 
+        */
161
 
162
 
+       fprintf(stderr,"RSA_dee_private_decrypt\n");
163
 
+       fprintf(stderr,"hSession=0x%lx hObject=0x%lx\n", hSession, hObject);
164
 
+ #endif
165
 
166
 
+       switch (padding) {
167
 
+               case RSA_PKCS1_PADDING:
168
 
+                       pMech = &m_rsa_pkcs;
169
 
+                       break;
170
 
+               case RSA_NO_PADDING:
171
 
+                       pMech = &m_rsa_raw;
172
 
+                       break;
173
 
+               case RSA_SSLV23_PADDING:
174
 
+               default:
175
 
+                       RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,RSA_R_UNKNOWN_PADDING_TYPE);
176
 
+       }
177
 
+       if (pMech == NULL) {
178
 
+               return 0; 
179
 
+       }
180
 
181
 
+       ulsiglen=BN_num_bytes(rsa->n);     
182
 
183
 
+         ck_status = C_SignRecoverInit(hSession, pMech, hObject);
184
 
+       if (ck_status != CKR_OK) {
185
 
+                 SCerr(SCERR_F_RSA_DECRYPT,SCERR_R_SIGNRECINIT);
186
 
+               ERR_add_error_data(1,sc_ERR_code(ck_status));
187
 
+               return 0;
188
 
+       }
189
 
+       ck_status = C_SignRecover(hSession,
190
 
+               from, flen, to, &ulsiglen);
191
 
+       if (ck_status != CKR_OK) {
192
 
+                 SCerr(SCERR_F_RSA_DECRYPT,SCERR_R_SIGNREC);
193
 
+               ERR_add_error_data(1,sc_ERR_code(ck_status));
194
 
+               return 0;
195
 
+       }  
196
 
+       return ulsiglen;        
197
 
198
 
199
 
+ #if 0
200
 
        ctx=BN_CTX_new();
201
 
        if (ctx == NULL) goto err;
202
 
  
203
 
204
 
        num=BN_num_bytes(rsa->n);
205
 
  
206
 
207
 
        if ((buf=(unsigned char *)Malloc(num)) == NULL)
208
 
                {
209
 
                RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE);
210
 
***************
211
 
*** 339,344 ****
212
 
--- 460,466 ----
213
 
                Free(buf);
214
 
                }
215
 
        return(r);
216
 
+ #endif
217
 
        }
218
 
  
219
 
  static int RSA_eay_public_decrypt(flen, from, to, rsa, padding)
220
 
***************
221
 
*** 479,485 ****
222
 
--- 601,609 ----
223
 
  static int RSA_eay_init(rsa)
224
 
  RSA *rsa;
225
 
        {
226
 
+ #if 0
227
 
        rsa->flags|=RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE;
228
 
+ #endif
229
 
        return(1);
230
 
        }
231