Debian Codegraph @

dkim/arcverify.py

raw symbols SCIP
1 #!/usr/bin/env python
2
3 # This software is provided 'as-is', without any express or implied
4 # warranty. In no event will the author be held liable for any damages
5 # arising from the use of this software.
6 #
7 # Permission is granted to anyone to use this software for any purpose,
8 # including commercial applications, and to alter it and redistribute it
9 # freely, subject to the following restrictions:
10 #
11 # 1. The origin of this software must not be misrepresented; you must not
12 # claim that you wrote the original software. If you use this software
13 # in a product, an acknowledgment in the product documentation would be
14 # appreciated but is not required.
15 # 2. Altered source versions must be plainly marked as such, and must not be
16 # misrepresented as being the original software.
17 # 3. This notice may not be removed or altered from any source distribution.
18 #
19 # Copyright (c) 2008 Greg Hewgill http://hewgill.com
20 #
21 # This has been modified from the original software.
22 # Copyright (c) 2011 William Grant <[email protected]>
23 #
24 # This has been modified from the original software.
25 # Copyright (c) 2016 Google, Inc.
26 # Contact: Brandon Long <[email protected]>
27
28 from __future__ import print_function
29
30 import logging
31 import sys
32
33 import dkim
34
35
36 def main():
37 if sys.version_info[0] >= 3:
38 # Make sys.stdin a binary stream.
39 sys.stdin = sys.stdin.detach()
40
41 message = sys.stdin.read()
42 verbose = '-v' in sys.argv
43 if verbose:
44 logging.basicConfig(level=10)
45 a = dkim.ARC(message)
46 cv, results, comment = a.verify()
47 else:
48 cv, results, comment = dkim.arc_verify(message)
49
50 print("arc verification: cv=%s %s" % (cv, comment))
51 if verbose:
52 print(repr(results))
53
54
55 if __name__ == "__main__":
56 main()