db_connect. Database helper for connecting to or initializing the SQLite database. This docstring was expanded to make future maintenance easier. Returns: Varies.
()
| 648 | """ |
| 649 | with open(src_path, "rb") as f: |
| 650 | hdr = f.read(HDR_LEN) |
| 651 | if len(hdr) != HDR_LEN or hdr[:len(MAGIC)] != MAGIC: |
| 652 | raise ValueError("Not an encrypted ButSystem blob.") |
| 653 | nonce = hdr[len(MAGIC):len(MAGIC)+NONCE_LEN] |
| 654 | tag = hdr[len(MAGIC)+NONCE_LEN:HDR_LEN] |
| 655 | |
| 656 | cipher = Cipher(algorithms.AES(MASTER_KEY), modes.GCM(nonce, tag)) |
| 657 | decryptor = cipher.decryptor() |
| 658 | |
| 659 | while True: |
| 660 | chunk = f.read(CHUNK) |
| 661 | if not chunk: |
| 662 | break |
| 663 | out = decryptor.update(chunk) |
| 664 | if out: |
| 665 | yield out |
| 666 | out = decryptor.finalize() |
no outgoing calls
no test coverage detected