OLD | NEW |
1 /* | 1 /* |
2 * gf2_8.c | 2 * gf2_8.c |
3 * | 3 * |
4 * GF(256) finite field implementation, with the representation used | 4 * GF(256) finite field implementation, with the representation used |
5 * in the AES cipher. | 5 * in the AES cipher. |
6 * | 6 * |
7 * David A. McGrew | 7 * David A. McGrew |
8 * Cisco Systems, Inc. | 8 * Cisco Systems, Inc. |
9 */ | 9 */ |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
39 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 39 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
43 * OF THE POSSIBILITY OF SUCH DAMAGE. | 43 * OF THE POSSIBILITY OF SUCH DAMAGE. |
44 * | 44 * |
45 */ | 45 */ |
46 | 46 |
47 | 47 |
| 48 #ifdef HAVE_CONFIG_H |
| 49 #include <config.h> |
| 50 #endif |
| 51 |
48 #include "datatypes.h" | 52 #include "datatypes.h" |
49 #include "gf2_8.h" | 53 #include "gf2_8.h" |
50 | 54 |
51 /* gf2_8_shift() moved to gf2_8.h as an inline function */ | 55 /* gf2_8_shift() moved to gf2_8.h as an inline function */ |
52 | 56 |
53 gf2_8 | 57 gf2_8 |
54 gf2_8_multiply(gf2_8 x, gf2_8 y) { | 58 gf2_8_multiply(gf2_8 x, gf2_8 y) { |
55 gf2_8 z = 0; | 59 gf2_8 z = 0; |
56 | 60 |
57 if (y & 1) z ^= x; x = gf2_8_shift(x); | 61 if (y & 1) z ^= x; x = gf2_8_shift(x); |
(...skipping 16 matching lines...) Expand all Loading... |
74 unsigned int i; | 78 unsigned int i; |
75 | 79 |
76 if (x == 0) return 0; /* zero is a special case */ | 80 if (x == 0) return 0; /* zero is a special case */ |
77 for (i=0; i < 256; i++) | 81 for (i=0; i < 256; i++) |
78 if (gf2_8_multiply((gf2_8) i, x) == 1) | 82 if (gf2_8_multiply((gf2_8) i, x) == 1) |
79 return (gf2_8) i; | 83 return (gf2_8) i; |
80 | 84 |
81 return 0; | 85 return 0; |
82 } | 86 } |
83 | 87 |
OLD | NEW |