2016-05-18 02:52:22 +08:00
|
|
|
/*
|
2020-04-23 20:55:52 +08:00
|
|
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
1998-12-21 18:52:47 +08:00
|
|
|
*
|
2018-12-06 20:19:23 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:52:22 +08:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
1998-12-21 18:52:47 +08:00
|
|
|
*/
|
|
|
|
|
2020-01-02 22:25:27 +08:00
|
|
|
/*
|
|
|
|
* BF low level APIs are deprecated for public use, but still ok for internal
|
|
|
|
* use.
|
|
|
|
*/
|
|
|
|
#include "internal/deprecated.h"
|
|
|
|
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/blowfish.h>
|
2019-09-28 06:45:40 +08:00
|
|
|
#include "bf_local.h"
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/opensslv.h>
|
1998-12-21 18:52:47 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' (From
|
2000-02-04 07:23:24 +08:00
|
|
|
* LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, CAMBRIDGE
|
1998-12-21 18:52:47 +08:00
|
|
|
* SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
|
|
|
|
*/
|
|
|
|
|
1999-04-20 05:31:43 +08:00
|
|
|
const char *BF_options(void)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
2017-10-17 22:04:09 +08:00
|
|
|
return "blowfish(ptr)";
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
|
|
|
|
2000-02-08 22:19:14 +08:00
|
|
|
void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
const BF_KEY *key, int encrypt)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
|
|
|
BF_LONG l, d[2];
|
|
|
|
|
|
|
|
n2l(in, l);
|
2015-01-22 11:40:55 +08:00
|
|
|
d[0] = l;
|
1998-12-21 18:52:47 +08:00
|
|
|
n2l(in, l);
|
2015-01-22 11:40:55 +08:00
|
|
|
d[1] = l;
|
1998-12-21 18:56:39 +08:00
|
|
|
if (encrypt)
|
2000-02-08 22:19:14 +08:00
|
|
|
BF_encrypt(d, key);
|
2015-01-22 11:40:55 +08:00
|
|
|
else
|
2000-02-08 22:19:14 +08:00
|
|
|
BF_decrypt(d, key);
|
2015-01-22 11:40:55 +08:00
|
|
|
l = d[0];
|
1998-12-21 18:52:47 +08:00
|
|
|
l2n(l, out);
|
2015-01-22 11:40:55 +08:00
|
|
|
l = d[1];
|
1998-12-21 18:52:47 +08:00
|
|
|
l2n(l, out);
|
2015-01-22 11:40:55 +08:00
|
|
|
l = d[0] = d[1] = 0;
|
|
|
|
}
|