| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 |
| 15 | #include <assert.h> |
| 16 |
| 17 | #include <openssl/aes.h> |
| 18 |
| 19 | #include "../fipsmodule/bcm_interface.h" |
| 20 |
| 21 | void AES_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key) { |
| 22 | BCM_aes_encrypt(in, out, key); |
| 23 | } |
| 24 |
| 25 | void AES_decrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key) { |
| 26 | BCM_aes_decrypt(in, out, key); |
| 27 | } |
| 28 |
| 29 | int AES_set_encrypt_key(const uint8_t *key, unsigned bits, AES_KEY *aeskey) { |
| 30 | if (bits != 128 && bits != 192 && bits != 256) { |
| 31 | return -2; |
| 32 | } |
| 33 | return bcm_success(BCM_aes_set_encrypt_key(key, bits, aeskey)) ? 0 : -1; |
| 34 | } |
| 35 |
| 36 | int AES_set_decrypt_key(const uint8_t *key, unsigned bits, AES_KEY *aeskey) { |
| 37 | if (bits != 128 && bits != 192 && bits != 256) { |
| 38 | return -2; |
| 39 | } |
| 40 | return bcm_success(BCM_aes_set_decrypt_key(key, bits, aeskey)) ? 0 : -1; |
| 41 | } |
| 42 |