title: Breaking down RSA/ECB/OAEPWithSHA-256AndMGF1Padding
body: <p>Java has a mode called <code>RSA/ECB/OAEPWithSHA-256AndMGF1Padding</code>. What does that even mean?</p>
  <p><a href="https://www.rfc-editor.org/rfc/rfc3447#section-7.1.2" rel="nofollow noreferrer">RFC3447</a>, <em>Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography Specifications Version 2.1</em>, section <em>7.1.2 Decryption operation</em> says Hash and MGF are both options for RSAES-OAEP-DECRYPT. MGF is it's own function, defined in <em>Section B.2.1 MGF1</em> and that has it's own Hash &quot;option&quot; as well.</p>
  <p>Maybe the Hash &quot;option&quot; in RSAES-OAEP-DECRYPT and MGF1 are supposed to be the same or maybe they're not, it is unclear to me. If they are then I guess when you have <code>RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING</code> that means sha256 should be used for both. But if they're not supposed to be the same then you could have sha256 used for RSAES-OAEP-DECRYPT and, for example, sha1 used for MGF1. And if that's the case then what function is sha256 supposed to be used for? And what hash algorithm is supposed to be used for the other function?</p>
  <p>And what does ECB mean in this context? ECB is a symmetric block cipher mode. Electronic Code Book. Maybe it's supposed to mean how Java deals with plaintext's that are larger than the modulo? Like maybe splits the plaintext into chunks that are as big as the modulo and then encrypts each one with RSA and concatenates them together? I'm just guessing..</p>