'Ensure the resource is in its desired state.'

def check(self, module, perms_required=True):

    state_and_perms = super(PublicKey, self).check(module, perms_required)
    def _check_privatekey():
        if (not os.path.exists(self.privatekey_path)):
            return False
        current_publickey = crypto.dump_publickey(crypto.FILETYPE_ASN1, crypto.load_publickey(crypto.FILETYPE_PEM, open(self.path, 'rb').read()))
        desired_publickey = crypto.dump_publickey(crypto.FILETYPE_ASN1, crypto_utils.load_privatekey(self.privatekey_path, self.privatekey_passphrase))
        return (hashlib.md5(current_publickey).hexdigest() == hashlib.md5(desired_publickey).hexdigest())
    if (not state_and_perms):
        return state_and_perms
    return _check_privatekey()
