| OLD | NEW |
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | 4 |
| 5 /* | 5 /* |
| 6 * token.c | 6 * token.c |
| 7 * | 7 * |
| 8 * This file implements the NSSCKFWToken type and methods. | 8 * This file implements the NSSCKFWToken type and methods. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 error = fwToken->mdToken->GetUTCTime(fwToken->mdToken, fwToken, | 1251 error = fwToken->mdToken->GetUTCTime(fwToken->mdToken, fwToken, |
| 1252 fwToken->mdInstance, fwToken->fwInstance, utcTime); | 1252 fwToken->mdInstance, fwToken->fwInstance, utcTime); |
| 1253 if( CKR_OK != error ) { | 1253 if( CKR_OK != error ) { |
| 1254 return error; | 1254 return error; |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 /* Sanity-check the data */ | 1257 /* Sanity-check the data */ |
| 1258 { | 1258 { |
| 1259 /* Format is YYYYMMDDhhmmss00 */ | 1259 /* Format is YYYYMMDDhhmmss00 */ |
| 1260 int i; | 1260 int i; |
| 1261 int Y, M, D, h, m, s, z; | 1261 int Y, M, D, h, m, s; |
| 1262 static int dims[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | 1262 static int dims[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
| 1263 | 1263 |
| 1264 for( i = 0; i < 16; i++ ) { | 1264 for( i = 0; i < 16; i++ ) { |
| 1265 if( (utcTime[i] < '0') || (utcTime[i] > '9') ) { | 1265 if( (utcTime[i] < '0') || (utcTime[i] > '9') ) { |
| 1266 goto badtime; | 1266 goto badtime; |
| 1267 } | 1267 } |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 Y = ((utcTime[ 0] - '0') * 1000) + ((utcTime[1] - '0') * 100) + | 1270 Y = ((utcTime[ 0] - '0') * 1000) + ((utcTime[1] - '0') * 100) + |
| 1271 ((utcTime[ 2] - '0') * 10) + (utcTime[ 3] - '0'); | 1271 ((utcTime[ 2] - '0') * 10) + (utcTime[ 3] - '0'); |
| 1272 M = ((utcTime[ 4] - '0') * 10) + (utcTime[ 5] - '0'); | 1272 M = ((utcTime[ 4] - '0') * 10) + (utcTime[ 5] - '0'); |
| 1273 D = ((utcTime[ 6] - '0') * 10) + (utcTime[ 7] - '0'); | 1273 D = ((utcTime[ 6] - '0') * 10) + (utcTime[ 7] - '0'); |
| 1274 h = ((utcTime[ 8] - '0') * 10) + (utcTime[ 9] - '0'); | 1274 h = ((utcTime[ 8] - '0') * 10) + (utcTime[ 9] - '0'); |
| 1275 m = ((utcTime[10] - '0') * 10) + (utcTime[11] - '0'); | 1275 m = ((utcTime[10] - '0') * 10) + (utcTime[11] - '0'); |
| 1276 s = ((utcTime[12] - '0') * 10) + (utcTime[13] - '0'); | 1276 s = ((utcTime[12] - '0') * 10) + (utcTime[13] - '0'); |
| 1277 z = ((utcTime[14] - '0') * 10) + (utcTime[15] - '0'); | |
| 1278 | 1277 |
| 1279 if( (Y < 1990) || (Y > 3000) ) goto badtime; /* Y3K problem. heh heh heh */ | 1278 if( (Y < 1990) || (Y > 3000) ) goto badtime; /* Y3K problem. heh heh heh */ |
| 1280 if( (M < 1) || (M > 12) ) goto badtime; | 1279 if( (M < 1) || (M > 12) ) goto badtime; |
| 1281 if( (D < 1) || (D > 31) ) goto badtime; | 1280 if( (D < 1) || (D > 31) ) goto badtime; |
| 1282 | 1281 |
| 1283 if( D > dims[M-1] ) goto badtime; /* per-month check */ | 1282 if( D > dims[M-1] ) goto badtime; /* per-month check */ |
| 1284 if( (2 == M) && (((Y%4)||!(Y%100))&&(Y%400)) && (D > 28) ) goto badtime; /*
leap years */ | 1283 if( (2 == M) && (((Y%4)||!(Y%100))&&(Y%400)) && (D > 28) ) goto badtime; /*
leap years */ |
| 1285 | 1284 |
| 1286 if( (h < 0) || (h > 23) ) goto badtime; | 1285 if( (h < 0) || (h > 23) ) goto badtime; |
| 1287 if( (m < 0) || (m > 60) ) goto badtime; | 1286 if( (m < 0) || (m > 60) ) goto badtime; |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 ) | 1882 ) |
| 1884 { | 1883 { |
| 1885 #ifdef DEBUG | 1884 #ifdef DEBUG |
| 1886 if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) { | 1885 if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) { |
| 1887 return CKS_RO_PUBLIC_SESSION; | 1886 return CKS_RO_PUBLIC_SESSION; |
| 1888 } | 1887 } |
| 1889 #endif /* DEBUG */ | 1888 #endif /* DEBUG */ |
| 1890 | 1889 |
| 1891 return nssCKFWToken_GetSessionState(fwToken); | 1890 return nssCKFWToken_GetSessionState(fwToken); |
| 1892 } | 1891 } |
| OLD | NEW |