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

Unified Diff: crypto/kernel/err.c

Issue 2344973002: Update libsrtp to version 2.0 (Closed)
Patch Set: Add '.' back to include_dirs Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto/kernel/crypto_kernel.c ('k') | crypto/kernel/key.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/kernel/err.c
diff --git a/srtp/crypto/math/gf2_8.c b/crypto/kernel/err.c
similarity index 56%
rename from srtp/crypto/math/gf2_8.c
rename to crypto/kernel/err.c
index c57f8d232a7459a84c1da498ec11d590b339042e..5931bb4879d88d57c6b30037ef18a39d3df447e1 100644
--- a/srtp/crypto/math/gf2_8.c
+++ b/crypto/kernel/err.c
@@ -1,34 +1,32 @@
/*
- * gf2_8.c
+ * err.c
+ *
+ * error status reporting functions
*
- * GF(256) finite field implementation, with the representation used
- * in the AES cipher.
- *
* David A. McGrew
* Cisco Systems, Inc.
*/
-
/*
- *
- * Copyright (c) 2001-2006, Cisco Systems, Inc.
+ *
+ * Copyright(c) 2001-2006 Cisco Systems, Inc.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- *
+ *
* Neither the name of the Cisco Systems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -44,44 +42,58 @@
*
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include "datatypes.h"
-#include "gf2_8.h"
+#include "err.h"
-/* gf2_8_shift() moved to gf2_8.h as an inline function */
-gf2_8
-gf2_8_multiply(gf2_8 x, gf2_8 y) {
- gf2_8 z = 0;
+/* srtp_err_level reflects the level of errors that are reported */
- if (y & 1) z ^= x; x = gf2_8_shift(x);
- if (y & 2) z ^= x; x = gf2_8_shift(x);
- if (y & 4) z ^= x; x = gf2_8_shift(x);
- if (y & 8) z ^= x; x = gf2_8_shift(x);
- if (y & 16) z ^= x; x = gf2_8_shift(x);
- if (y & 32) z ^= x; x = gf2_8_shift(x);
- if (y & 64) z ^= x; x = gf2_8_shift(x);
- if (y & 128) z ^= x;
-
- return z;
-}
+srtp_err_reporting_level_t srtp_err_level = srtp_err_level_none;
+
+/* srtp_err_file is the FILE to which errors are reported */
+
+static FILE *srtp_err_file = NULL;
+
+srtp_err_status_t srtp_err_reporting_init (const char *ident)
+{
+ /*
+ * Believe it or not, openlog doesn't return an error on failure.
+ * But then, neither does the syslog() call...
+ */
-/* this should use the euclidean algorithm */
+#ifdef ERR_REPORTING_STDOUT
+ srtp_err_file = stdout;
+#elif defined(USE_ERR_REPORTING_FILE)
+ /* open file for error reporting */
+ srtp_err_file = fopen(ERR_REPORTING_FILE, "w");
+ if (srtp_err_file == NULL) {
+ return srtp_err_status_init_fail;
+ }
+#endif
+
+ return srtp_err_status_ok;
+}
-gf2_8
-gf2_8_compute_inverse(gf2_8 x) {
- unsigned int i;
+void srtp_err_report (int priority, const char *format, ...)
+{
+ va_list args;
- if (x == 0) return 0; /* zero is a special case */
- for (i=0; i < 256; i++)
- if (gf2_8_multiply((gf2_8) i, x) == 1)
- return (gf2_8) i;
+ if (priority <= srtp_err_level) {
- return 0;
+ va_start(args, format);
+ if (srtp_err_file != NULL) {
+ vfprintf(srtp_err_file, format, args);
+ /* fprintf(srtp_err_file, "\n"); */
+ }
+ va_end(args);
+ }
}
+void srtp_err_reporting_set_level (srtp_err_reporting_level_t lvl)
+{
+ srtp_err_level = lvl;
+}
« no previous file with comments | « crypto/kernel/crypto_kernel.c ('k') | crypto/kernel/key.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698