may help you . Your requirements are reasonable, but your proposed solution is fundamentally flawed and should be abandoned. You should go back to your requirements and seek to achieve those requirements using the standard techniques and APIs.
Any of those help The Data Protection API hands you back an opaque blob that is the encrypted (and salted, and hashed) result of what you wanted encrypted. You cannot "fill up" the DP API - you would only "fill up" yourself (as the blobs are somewhat large; but they do internally contain everything need to later verify the encrypted data).
RSA_public_encrypt returning -1 and not able to decrypt, RSA 2048-bit with padding is used for encrypting and decrypting
will help you You can't encrypt a full 256 byte block with 2048 bit key as the padding uses some of the space. A PKCS1 padding uses around 11 bytes. In practice this means that you encrypted data is going to be growing in size. Generally RSA is not suited for bulk encryption as it's quite slow (more than a factor 1000 when compared to AES). Instead use a symmetric encryption algorithm like AES if you can. If you really need the two key's of RSA, use a Hybrid approach where you encrypt the data with a random symmetric key, and then encrypt that key with the RSA key.
With these it helps There are two problems with the current code. The code is not scaleable as the number of blocks are fixed. Incorrect indexing inside the kernel. Global index j does not scale with changing number of blocks.