File: fko-python.py

package info (click to toggle)
fwknop 2.6.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,420 kB
  • sloc: ansic: 30,106; perl: 20,346; sh: 5,560; makefile: 955; xml: 937; python: 797; java: 444; objc: 292; erlang: 128
file content (48 lines) | stat: -rwxr-xr-x 1,331 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python

#
# Import the Fko class and all constants.
#
from fko import *

def main():

    # Create an Fko instance with an empty context.
    #
    fko = Fko()

    # Set the HMAC digest algorithm
    #
    fko.hmac_type(FKO_HMAC_SHA512)

    # Set the SPA message (Note: Access request is default if not specified).
    #
    fko.spa_message("127.0.0.2,tcp/22")

    # Create the final SPA data message string.
    #
    fko.spa_data_final("testkey1", "testkey2")

    # print the spa message.
    #
    print "SPA packet data:", fko.spa_data()

    # Print some of the data:
    #
    print "Version:", fko.version()
    print "Timestamp:", fko.timestamp()
    print "Username:", fko.username()
    print "Encryption Type (value):", fko.encryption_type()
    print "Encryption Type (string):", fko.encryption_type_str()
    print "Encryption Mode (value):", fko.encryption_mode()
    print "Encryption Mode (string):", fko.encryption_mode_str()
    print "Digest Type (value):", fko.digest_type()
    print "Digest Type (string):", fko.digest_type_str()
    print "Digest:", fko.spa_digest()
    print "HMAC Type (value):", fko.hmac_type()
    print "HMAC Type (string):", fko.hmac_type_str()
    print "HMAC:", fko.get_spa_hmac()
    print "SPA Message:", fko.spa_message()

if __name__ == "__main__":
    main()