Well, you _are_ sacrificing speed because you're copying too much data. And saying it's local is probably wrong; I'm pretty sure the PEM functions use BIO_gets().