Exemple #1
0
 def verify(self, buf, sig, max_age=None):
     buf = make_buf(buf)
     sig = encode_str(sig)
     if max_age is None:
         return self._methodcall(lib.semaphore_publickey_verify, buf, sig)
     return self._methodcall(lib.semaphore_publickey_verify_timestamp, buf,
                             sig, max_age)
Exemple #2
0
 def verify(self, buf, sig, max_age=None):
     buf = make_buf(buf)
     sig = encode_str(sig)
     if max_age is None:
         return self._methodcall(lib.semaphore_publickey_verify, buf, sig)
     return self._methodcall(
         lib.semaphore_publickey_verify_timestamp, buf, sig, max_age
     )
Exemple #3
0
def create_register_challenge(data, signature, max_age=60 * 15):
    rv = json.loads(
        decode_str(
            rustcall(lib.semaphore_create_register_challenge, make_buf(data),
                     encode_str(signature), max_age)))
    return {
        'relay_id': uuid.UUID(rv['relay_id']),
        'public_key': PublicKey.parse(rv['public_key']),
        'token': rv['token'],
    }
Exemple #4
0
def validate_register_response(public_key, data, signature, max_age=60 * 15):
    rv = json.loads(
        decode_str(
            rustcall(lib.semaphore_validate_register_response,
                     public_key._objptr, make_buf(data), encode_str(signature),
                     max_age)))
    return {
        'relay_id': uuid.UUID(rv['relay_id']),
        'token': rv['token'],
    }
Exemple #5
0
def validate_register_response(public_key, data, signature, max_age=60 * 15):
    rv = json.loads(
        decode_str(
            rustcall(
                lib.semaphore_validate_register_response,
                public_key._objptr,
                make_buf(data),
                encode_str(signature),
                max_age,
            )
        )
    )
    return {"relay_id": uuid.UUID(rv["relay_id"]), "token": rv["token"]}
Exemple #6
0
def create_register_challenge(data, signature, max_age=60 * 15):
    rv = json.loads(
        decode_str(
            rustcall(
                lib.semaphore_create_register_challenge,
                make_buf(data),
                encode_str(signature),
                max_age,
            )
        )
    )
    return {
        "relay_id": uuid.UUID(rv["relay_id"]),
        "public_key": PublicKey.parse(rv["public_key"]),
        "token": rv["token"],
    }
Exemple #7
0
 def sign(self, value):
     buf = make_buf(value)
     return decode_str(
         self._methodcall(lib.semaphore_secretkey_sign, buf), free=True
     )
Exemple #8
0
def get_register_response_relay_id(data):
    return decode_uuid(
        rustcall(lib.semaphore_get_register_response_relay_id, make_buf(data))
    )