| 1437 | } |
| 1438 | |
| 1439 | void CryptoManager::calcDigitalSignature(thread_db* tdbb, string& signature, const Header& hdr) |
| 1440 | { |
| 1441 | /* |
| 1442 | We use the following items to calculate digital signature (hash of encrypted string) |
| 1443 | for database: |
| 1444 | hdr_flags & (hdr_crypt_process | hdr_encrypted) |
| 1445 | hdr_crypt_page |
| 1446 | hdr_crypt_plugin |
| 1447 | HDR_crypt_key |
| 1448 | HDR_crypt_hash |
| 1449 | */ |
| 1450 | |
| 1451 | signature.printf("%d %d %d %s", |
| 1452 | (hdr->hdr_flags & Ods::hdr_crypt_process ? 1 : 0), |
| 1453 | (hdr->hdr_flags & Ods::hdr_encrypted ? 1 : 0), |
| 1454 | hdr->hdr_crypt_page, |
| 1455 | hdr->hdr_crypt_plugin); |
| 1456 | |
| 1457 | ClumpletWriter hc(ClumpletWriter::UnTagged, hdr->hdr_page_size); |
| 1458 | hdr.getClumplets(hc); |
| 1459 | |
| 1460 | addClumplet(signature, hc, Ods::HDR_crypt_key); |
| 1461 | addClumplet(signature, hc, Ods::HDR_crypt_hash); |
| 1462 | |
| 1463 | const unsigned QUANTUM = 16; |
| 1464 | signature += string(QUANTUM - 1, '$'); |
| 1465 | unsigned len = signature.length(); |
| 1466 | len &= ~(QUANTUM - 1); |
| 1467 | |
| 1468 | loadPlugin(tdbb, hdr->hdr_crypt_plugin); |
| 1469 | |
| 1470 | string enc; |
| 1471 | FbLocalStatus sv; |
| 1472 | cryptPlugin->encrypt(&sv, len, signature.c_str(), enc.getBuffer(len)); |
| 1473 | if (sv->getState() & IStatus::STATE_ERRORS) |
| 1474 | Arg::StatusVector(&sv).raise(); |
| 1475 | |
| 1476 | Sha1::hashBased64(signature, enc); |
| 1477 | } |
| 1478 | |
| 1479 | |
| 1480 | void CryptoManager::digitalySignDatabase(thread_db* tdbb, CchHdr& hdr) |
nothing calls this directly
no test coverage detected