![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Encrypt large data files chunk-by-chunk, securely.
This package uses AES in GCM mode to encrypt and decrypt file streams.
It relies on the cryptography library to perform the encryption.
big unencrypted file, verification data --> encrypt and sign --> encrypted file, iv, tag
big unencrypted file <-- decrypt and verify <-- encrypted file, iv, tag, verification data
The aesgcm
module provides a way to encrypt and decrypt entire files without loading the entire thing into memory. It does not provide a file-like interface to the encrypted file.
import os
from buffered_encryption.aesgcm import EncryptionIterator, DecryptionIterator
plaintext = open("plain.txt","rb")
key = os.urandom(32)
sig = os.urandom(12)
enc = EncryptionIterator(plaintext,key,sig)
with open("cipher","wb") as ciphertext:
for chunk in enc:
ciphertext.write(chunk)
plaintext.close()
ciphertext = open("cipher","rb")
dec = DecryptionIterator(ciphertext,key,sig,enc.iv,enc.tag)
with open("plain.dec.txt","wb") as decrypted:
for chunk in dec:
decrypted.write(chunk)
ciphertext.close()
The aesctr
module allows you to read and seek an encrypted file as if it was a normal file. This provides a file-like interface while the data on disk stays encrypted.
This will be on the disk:
b"1\xb2<\xcco\xbb\xa5%\xa9\xce\xb0\xac\x12\xc1Cw {\xdd\x0c\xa1\x93\x1b'E=v4L\xb8\xb9\x0e\xd5\x90\x8d\xf3H \xeb\x99iX\xcf\xea\xfc\xac\x92\xe8\xff\xb3\xbbS\xcaM\xb2\xf3?\xdf\xd9\x80\xbf\xef\x06\xa2\xab\x977\xc0\xcc\x0f\xd6\xd6' ,"
This will be what you read into python:
b"Hello, World!! This message is longer than the AES block size of 16 bytes!!"
Key and nonce used in the above:
key = b'\x0e\x07)\xb8*\xda\x13\x19\xc7`"\x14\xc1i\xe3\xf1$\xa5\xc7w\xda\x1dU\t\x9c\x1f{\xf5tR\xa7b'
nonce = b'6\x03\xf5\xdd\x92\x17\x0cDg\xcc\x1a\x9f\xe1\x08\x98\x7f'
To recreate this:
import os, io
from buffered_encryption.aesctr import EncryptionIterator, ReadOnlyEncryptedFile
key = os.urandom(32)
nonce = os.urandom(16)
plaintext = b"Hello, World!! This message is longer than the AES block size of 16 bytes!!"
# Write the ciphertext to a buffer (you can also write to a file)
ciphertext_buf = io.BytesIO()
enc = EncryptionIterator(io.BytesIO(plaintext),key,nonce)
for chunk in enc:
ciphertext_buf.write(chunk)
ciphertext_buf.seek(0)
# Create our read-only encrypted file
ef = ReadOnlyEncryptedFile(ciphertext_buf,key,nonce)
# Read 12 bytes of data
ef.read(12) # returns b"Hello, World"
# Seekable
ef.seek(7)
# Keep reading
ef.read(18) # returns b"World!! This messa"
Read-only ensures you do not use the same nonce for different messages. You cannot write different data to a block using the same nonce, and still be cryptographically secure. So if you were to re-write to the encrypted file, you have now defeated your own encryption.
FAQs
Encrypt large files without loading the entire file into memory.
We found that buffered-encryption demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.