00001
00002
00003 const char *XrdCryptoRSACVSID = "$Id: XrdCryptoRSA.cc 30949 2009-11-02 16:37:58Z ganis $";
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <string.h>
00023
00024 #include <XrdCrypto/XrdCryptoRSA.hh>
00025
00026 const char *XrdCryptoRSA::cstatus[3] = { "Invalid", "Public", "Complete" };
00027
00028
00029 void XrdCryptoRSA::Dump()
00030 {
00031
00032 ABSTRACTMETHOD("XrdCryptoRSA::Dump");
00033 }
00034
00035
00036 XrdCryptoRSAdata XrdCryptoRSA::Opaque()
00037 {
00038
00039 ABSTRACTMETHOD("XrdCryptoRSA::Opaque");
00040 return (XrdCryptoRSAdata)0;
00041 }
00042
00043
00044 int XrdCryptoRSA::GetOutlen(int)
00045 {
00046
00047 ABSTRACTMETHOD("XrdCryptoRSA::GetOutlen");
00048 return 0;
00049 }
00050
00051
00052 int XrdCryptoRSA::GetPublen()
00053 {
00054
00055 ABSTRACTMETHOD("XrdCryptoRSA::GetPublen");
00056 return 0;
00057 }
00058
00059
00060 int XrdCryptoRSA::GetPrilen()
00061 {
00062
00063 ABSTRACTMETHOD("XrdCryptoRSA::GetPrilen");
00064 return 0;
00065 }
00066
00067
00068 int XrdCryptoRSA::ImportPublic(const char *, int)
00069 {
00070
00071 ABSTRACTMETHOD("XrdCryptoRSA::ImportPublic");
00072 return -1;
00073 }
00074
00075
00076 int XrdCryptoRSA::ExportPublic(char *, int)
00077 {
00078
00079 ABSTRACTMETHOD("XrdCryptoRSA::ExportPublic");
00080 return -1;
00081 }
00082
00083
00084 int XrdCryptoRSA::ImportPrivate(const char *, int)
00085 {
00086
00087 ABSTRACTMETHOD("XrdCryptoRSA::ImportPrivate");
00088 return -1;
00089 }
00090
00091
00092 int XrdCryptoRSA::ExportPrivate(char *, int)
00093 {
00094
00095 ABSTRACTMETHOD("XrdCryptoRSA::ExportPrivate");
00096 return -1;
00097 }
00098
00099
00100 int XrdCryptoRSA::ExportPublic(XrdOucString &s)
00101 {
00102
00103
00104 int newlen = GetPublen();
00105 if (newlen > 0) {
00106 char *newbuf = new char[newlen+1];
00107 if (newbuf) {
00108 memset(newbuf, 0, newlen+1);
00109 if (ExportPublic(newbuf,newlen+1) > -1) {
00110 s = (const char *)newbuf;
00111 delete[] newbuf;
00112 return 0;
00113 }
00114 delete[] newbuf;
00115 }
00116 }
00117 return -1;
00118 }
00119
00120
00121 int XrdCryptoRSA::ExportPrivate(XrdOucString &s)
00122 {
00123
00124
00125 int newlen = GetPrilen();
00126 if (newlen > 0) {
00127 char *newbuf = new char[newlen+1];
00128 if (newbuf) {
00129 memset(newbuf, 0, newlen+1);
00130 if (ExportPrivate(newbuf,newlen+1) > -1) {
00131 s = (const char *)newbuf;
00132 delete[] newbuf;
00133 return 0;
00134 }
00135 delete[] newbuf;
00136 }
00137 }
00138 return -1;
00139 }
00140
00141
00142 int XrdCryptoRSA::EncryptPrivate(const char *, int, char *, int)
00143 {
00144
00145 ABSTRACTMETHOD("XrdCryptoRSA::EncryptPrivate");
00146 return -1;
00147 }
00148
00149
00150 int XrdCryptoRSA::EncryptPublic(const char *, int, char *, int)
00151 {
00152
00153 ABSTRACTMETHOD("XrdCryptoRSA::EncryptPublic");
00154 return -1;
00155 }
00156
00157
00158 int XrdCryptoRSA::DecryptPrivate(const char *, int, char *, int)
00159 {
00160
00161 ABSTRACTMETHOD("XrdCryptoRSA::DecryptPrivate");
00162 return -1;
00163 }
00164
00165
00166 int XrdCryptoRSA::DecryptPublic(const char *, int, char *, int)
00167 {
00168
00169 ABSTRACTMETHOD("XrdCryptoRSA::DecryptPublic");
00170 return -1;
00171 }
00172
00173
00174 int XrdCryptoRSA::EncryptPrivate(XrdSutBucket &bck)
00175 {
00176
00177
00178 int snew = -1;
00179
00180 int sz = GetOutlen(bck.size);
00181 char *newbuf = new char[sz];
00182 if (newbuf) {
00183 memset(newbuf, 0, sz);
00184 snew = EncryptPrivate(bck.buffer,bck.size,newbuf,sz);
00185 if (snew > -1)
00186 bck.Update(newbuf,snew);
00187 }
00188 return snew;
00189 }
00190
00191
00192 int XrdCryptoRSA::EncryptPublic(XrdSutBucket &bck)
00193 {
00194
00195
00196 int snew = -1;
00197
00198 int sz = GetOutlen(bck.size);
00199 char *newbuf = new char[sz];
00200 if (newbuf) {
00201 memset(newbuf, 0, sz);
00202 snew = EncryptPublic(bck.buffer,bck.size,newbuf,sz);
00203 if (snew > -1)
00204 bck.Update(newbuf,snew);
00205 }
00206 return snew;
00207 }
00208
00209
00210 int XrdCryptoRSA::DecryptPrivate(XrdSutBucket &bck)
00211 {
00212
00213
00214 int snew = -1;
00215
00216 int sz = GetOutlen(bck.size);
00217 char *newbuf = new char[sz];
00218 if (newbuf) {
00219 memset(newbuf, 0, sz);
00220 snew = DecryptPrivate(bck.buffer,bck.size,newbuf,sz);
00221 if (snew > -1)
00222 bck.Update(newbuf,snew);
00223 }
00224 return snew;
00225 }
00226
00227
00228 int XrdCryptoRSA::DecryptPublic(XrdSutBucket &bck)
00229 {
00230
00231
00232 int snew = -1;
00233
00234 int sz = GetOutlen(bck.size);
00235 char *newbuf = new char[sz];
00236 if (newbuf) {
00237 memset(newbuf, 0, sz);
00238 snew = DecryptPublic(bck.buffer,bck.size,newbuf,sz);
00239 if (snew > -1)
00240 bck.Update(newbuf,snew);
00241 }
00242 return snew;
00243 }