Skip to main content

Posts




Java RSA OAEP Padding — The Silent SHA-1 Trap

  Background We were implementing RSA-4096 encryption/decryption in a Java Spark pipeline We generated a key pair, shared the public key with the other team, and they sent back ciphertext encrypted using our public key. The Problem When we tried to decrypt the ciphertext using our private key, we got: Exception in thread "main" javax.crypto.BadPaddingException: Padding error in decryption at java.base/com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:387) at java.base/com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:422) at java.base/javax.crypto.Cipher.doFinal(Cipher.java:2205) Initial Suspects We went through the usual checklist: Same key pair — public key shared matches private key we hold Key format — private key correctly converted to PKCS#8 Base64 encoding — ciphertext not corrupted Algorithm — both sides using RSA with OAEP Everything looked correct. Keys were fine. Code looked fine. Yet decryption failed every time. Root Cause Our Java code used t...

Agentic AI Development- Optimization- Bedrock Claude

Most of the models which you wish to invoke via AWS Bedrock, GPT, Google, etc, charges per token ( words/ characters ) For example -  A model like Claude is not a computer program that executes instructions. It is a statistical pattern matcher trained on text. It has no CPU, no memory, no ability to run code. It only predicts the next most likely token based on patterns it saw during training. But, some AI platforms give the model a sandboxed Python environment to actually execute code. Bedrock does have a Code Interpreter tool in Bedrock Agents — but that's a completely different setup- the overhead of setting it up just to decompress JSON makes zero sense when simply sending clean JSON is trivially easy. Easy Way To Estimate Your Cost- Step 1 — Measure your actual prompt size: Take your evidence JSON + instructions Paste into: https://platform.openai.com/tokenizer (OpenAI's tokenizer is close enough for estimation) It will tell you exact token count Step2 - Cost calculation C...

VPN testing checklist

 To test: Is VPN active? Is it leaking? Does it look residential? Does it alter network fingerprints? Public IP Test (Basic Detection) - curl ipinfo.io DNS Leak Test - nslookup google.com MTU Test (Encapsulation Detection) - ping 8.8.8.8 -f -l 1472 TCP MSS Inspection - Use Wireshark and Look for SYN packets. Traceroute Path Test - tracert 8.8.8.8 WebRTC Leak Test - browserleaks.com/webrtc IPv6 Leak Test - test-ipv6.com Latency / Jitter Test - ping -n 50 8.8.8.8. VPN usually causes: More Jitters and Latency. Reverse DNS (PTR Record) - nslookup <your-public-ip> IP Reputation Check - Like most IP's from VPN Providers like Express VPN, etc. are blacklisted and all. Look for: Proxy/VPN classification, Hosting provider tagging

Unix Server ( Edge Node ) hangs when there are many jobs running on hadoop cluster started from Unix Edge Node.

  When a unix server or an edge node is running lots of jobs (like Spark, Hadoop, or custom batch processes), crashes happen. For example. For example a process might hit a segementation fault, memory issue or ay other runtime issue. By default, if ulimit -c is not 0, the OS will create core dump. Core dump are written to disk and can be very large, sometimes hundreds of MBs or even GBs per process. What we realized was that when multiple processes crash at the same time, the system suddenly tries to write core files to disk. This was leading to DisK I/O spikes. Thus, node was becoming unresponsive. This was also leading CPU spike because OS was handling crash logging. Setting "ulimit -c 0" disables core dumps. This way we lose ability to debug crashes via core dump But, kept production edge nodes stable. On most Linux systems, by default, "core dumps" are written in current working directory of the process that crashes. Linux allows you to change core dump file nam...

Spark leading to ClassNotFoundException for corrupt jar files instead of ZipException

  When Jar passed via --jars that leads to following error - zip END header not found Same Jar passed as application jar file leads to following error - ClassNotFoundException These two errors are not contradictory. They mean Spark is touching the Jar in 2 completely different code paths. --jars Jars are: Downloaded Immediately unpacked/ inspected Added to executor classpath eagerly. Thus if Jar is bad. Spark tries to open it as ZIP, which leads to ZipException. When used as application Jar: Spark does minimal Zip validation. Only checks enough to start Loads manifest + class index Attempts to resolve --class if: The Jar opens. But the expected class isn't there, which leads to ClassNotFoundException So: Spark never deeply unzips it Corruption in unused entries may go unnoticed Outcomes: As app JAR -> Spark reads just enough -> ClassNotFoundException As --jars -> Spark fully opens ZIP -> zip END header not found