# Path: beeswarm/shared/vnc/decoder.py
# class VNCDecoder(object):
#     def __init__(self, challenge, response, passwd_list):
#         self.challenge = challenge
#         self.response = response
#         self.passwd_list = passwd_list
# 
#     def decode(self):
#         for password in self.passwd_list:
#             password = password.strip('\n')
#             key = (password + '\0' * 8)[:8]
#             encryptor = RFBDes(key)
#             resp = encryptor.encrypt(self.challenge)
#             if resp == self.response:
#                 return key


import unittest
from beeswarm.shared.vnc.decoder import VNCDecoder
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Aniket Panse <contact@aniketpanse.in> grants Johnny Vestergaard <jkv@unixcluster.dk>
# a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
# copyright license to reproduce, prepare derivative works of, publicly
# display, publicly perform, sublicense, relicense, and distribute [the] Contributions
# and such derivative works.





class VncDecoderTests(unittest.TestCase):
    def test_combinations(self):
        """Tests different combinations of challenge/response pairs and checks if
           we can find the right password.
        """
        passwords = ['1q2w3e4r', 'asdf', '1234', 'beeswarm', 'random']


        # Real password is 1234
        challenge = '\x1f\x9c+\t\x14\x03\xfaj\xde\x97p\xe9e\xca\x08\xff'
        response = '\xe7\xe2\xe2\xa8\x89T\x87\x8d\xf01\x96\x10\xfe\xb9\xc5\xbb'


# Path: beeswarm/shared/vnc/decoder.py
# class VNCDecoder(object):
#     def __init__(self, challenge, response, passwd_list):
#         self.challenge = challenge
#         self.response = response
#         self.passwd_list = passwd_list
# 
#     def decode(self):
#         for password in self.passwd_list:
#             password = password.strip('\n')
#             key = (password + '\0' * 8)[:8]
#             encryptor = RFBDes(key)
#             resp = encryptor.encrypt(self.challenge)
#             if resp == self.response:
#                 return key


# Path: beeswarm/shared/tests/test_vncdecoder.py
import unittest
from beeswarm.shared.vnc.decoder import VNCDecoder

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Aniket Panse <contact@aniketpanse.in> grants Johnny Vestergaard <jkv@unixcluster.dk>
# a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
# copyright license to reproduce, prepare derivative works of, publicly
# display, publicly perform, sublicense, relicense, and distribute [the] Contributions
# and such derivative works.





class VncDecoderTests(unittest.TestCase):
    def test_combinations(self):
        """Tests different combinations of challenge/response pairs and checks if
           we can find the right password.
        """
        passwords = ['1q2w3e4r', 'asdf', '1234', 'beeswarm', 'random']


        # Real password is 1234
        challenge = '\x1f\x9c+\t\x14\x03\xfaj\xde\x97p\xe9e\xca\x08\xff'
        response = '\xe7\xe2\xe2\xa8\x89T\x87\x8d\xf01\x96\x10\xfe\xb9\xc5\xbb'


        decoder = VNCDecoder(challenge, response, passwords)