Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: srtp/crypto/test/aes_calc.c

Issue 889083003: Update libsrtp to upstream 1.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libsrtp@master
Patch Set: Minimal changes against upstream 1.5.0 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * aes_calc.c 2 * aes_calc.c
3 * 3 *
4 * A simple AES calculator for generating AES encryption values 4 * A simple AES calculator for generating AES encryption values
5 * 5 *
6 * David A. McGrew 6 * David A. McGrew
7 * Cisco Systems, Inc. 7 * Cisco Systems, Inc.
8 */ 8 */
9 /*
10 *
11 * Copyright (c) 2001-2006, Cisco Systems, Inc.
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials provided
24 * with the distribution.
25 *
26 * Neither the name of the Cisco Systems, Inc. nor the names of its
27 * contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
35 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
41 * OF THE POSSIBILITY OF SUCH DAMAGE.
42 *
43 */
44 9
45 /* 10 /*
46 11
47 Example usage (with first NIST FIPS 197 test case): 12 Example usage (with first NIST FIPS 197 test case):
48 13
49 [sh]$ test/aes_calc 000102030405060708090a0b0c0d0e0f 00112233445566778899aabbccd deeff -v 14 [sh]$ test/aes_calc 000102030405060708090a0b0c0d0e0f 00112233445566778899aabbccd deeff -v
50 plaintext: 00112233445566778899aabbccddeeff 15 plaintext: 00112233445566778899aabbccddeeff
51 key: 000102030405060708090a0b0c0d0e0f 16 key: 000102030405060708090a0b0c0d0e0f
52 ciphertext: 69c4e0d86a7b0430d8cdb78070b4c55a 17 ciphertext: 69c4e0d86a7b0430d8cdb78070b4c55a
53 18
54 */ 19 */
55 20
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24
56 #include "aes.h" 25 #include "aes.h"
57 #include <stdio.h> 26 #include <stdio.h>
58 #include <string.h> 27 #include <string.h>
59 28
60 void 29 void
61 usage(char *prog_name) { 30 usage(char *prog_name) {
62 printf("usage: %s <key> <plaintext> [-v]\n", prog_name); 31 printf("usage: %s <key> <plaintext> [-v]\n", prog_name);
63 exit(255); 32 exit(255);
64 } 33 }
65 34
66 #define AES_MAX_KEY_LEN 32 35 #define AES_MAX_KEY_LEN 32
67 36
68 int 37 int
69 main (int argc, char *argv[]) { 38 main (int argc, char *argv[]) {
70 v128_t data; 39 v128_t data;
71 uint8_t key[AES_MAX_KEY_LEN]; 40 uint8_t key[AES_MAX_KEY_LEN];
72 aes_expanded_key_t exp_key; 41 aes_expanded_key_t exp_key;
73 int key_len, len; 42 int key_len, len;
74 int verbose; 43 int verbose = 0;
75 err_status_t status; 44 err_status_t status;
76 45
77 if (argc == 3) { 46 if (argc == 3) {
78 /* we're not in verbose mode */ 47 /* we're not in verbose mode */
79 verbose = 0; 48 verbose = 0;
80 } else if (argc == 4) { 49 } else if (argc == 4) {
81 if (strncmp(argv[3], "-v", 2) == 0) { 50 if (strncmp(argv[3], "-v", 2) == 0) {
82 /* we're in verbose mode */ 51 /* we're in verbose mode */
83 verbose = 1; 52 verbose = 1;
84 } else { 53 } else {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 /* write ciphertext to output */ 114 /* write ciphertext to output */
146 if (verbose) { 115 if (verbose) {
147 printf("key:\t\t%s\n", octet_string_hex_string(key, key_len)); 116 printf("key:\t\t%s\n", octet_string_hex_string(key, key_len));
148 printf("ciphertext:\t"); 117 printf("ciphertext:\t");
149 } 118 }
150 printf("%s\n", v128_hex_string(&data)); 119 printf("%s\n", v128_hex_string(&data));
151 120
152 return 0; 121 return 0;
153 } 122 }
154 123
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698