This function verifies the token using the secret key and returns its
        contents.
511981
def read_session_token(secret_key, token):
    
    return jwt.decode(token.encode('utf-8'), secret_key,
        algorithms=[token_encryption_algorithm()]
    )
346965
def _get_access_token(self, verifier=None):
        
        
        response, content = self.client(verifier).request(
            self.access_token_url, "POST")
        
        content = smart_unicode(content)

        if not response['status'] == '200':
            raise OAuthError(_(
                u"Invalid status code %s while obtaining access token from %s: %s") % 
                (response['status'], self.access_token_url, content))
        
        token = dict(urlparse.parse_qsl(content))
        
        
        return (oauth.Token(token['oauth_token'], token['oauth_token_secret']),
            token)
563736
public static JWT verify(String jwt, String secret) {
    return verify(jwt, secret == null ? null : secret.getBytes(StandardCharsets.UTF_8));
  }
230795
def load_verifying_key(verifying_key, crypto_backend=default_backend()):
    
    if not isinstance(crypto_backend, (Backend, MultiBackend)):
        raise ValueError('backend must be a valid Backend object')

    if isinstance(verifying_key, EllipticCurvePublicKey):
        return verifying_key
    elif isinstance(verifying_key, (str, unicode)):
        try:
            return load_der_public_key(
                verifying_key, backend=crypto_backend)
        except:
            try:
                return load_pem_public_key(
                    verifying_key, backend=crypto_backend)
            except Exception:
                raise ValueError('Invalid verifying key format')
    else:
        raise ValueError('Invalid verification key type')
764517
function publicKeyVerify(key) {
  if (key.length === 0)
    return false;

  switch (key[0]) {
    case 0x02:
    case 0x03:
      return key.length === 33;
    case 0x04:
      if (key.length !== 65)
        return false;

      return secp256k1.publicKeyVerify(key);
    default:
      return false;
  }
}
562468
def _verify_auth(self):
        '''
        
        '''

        return self.token and bool(self.application.auth.get_tok(self.token))
216170
def get_jwt_secret():
    
    secret_key = __options__.get("jwt_secret") or config("JWT_SECRET") or config("SECRET_KEY")
    if not secret_key:
        raise exceptions.AuthError("Missing config JWT/SECRET_KEY")
    return secret_key
287138
def _get_signature(self):
        

        keys = list(self.params.keys())

        keys.sort()

        string = ""

        for name in keys:
            string += name
            string += self.params[name]

        string += self.api_secret

        return md5(string)
223848
def _decode(self, token, verify=True):
        
        secret = self._get_secret()
        algorithm = self._get_algorithm()
        kwargs = {}

        for claim in self.claims:
            if claim != "exp":
                setting = "claim_{}".format(claim.lower())
                if setting in self.config:  # noqa
                    value = self.config.get(setting)
                    kwargs.update({claim_label[claim]: value})

        kwargs["leeway"] = int(self.config.leeway())
        if "claim_aud" in self.config:  # noqa
            kwargs["audience"] = self.config.claim_aud()
        if "claim_iss" in self.config:  # noqa
            kwargs["issuer"] = self.config.claim_iss()

        decoded = jwt.decode(
            token,
            secret,
            algorithms=[algorithm],
            verify=verify,
            options={"verify_exp": self.config.verify_exp()},
            **kwargs
        )
        return decoded
728491
def _get_token(url, email, secret_key):
    '''
    
    '''
    url = urlparse.urljoin(url, 'authenticate')
    data_dict = {"email": email, "secret_key": secret_key}
    query = salt.utils.http.query(url, data=data_dict, method='POST',
                                  decode=True)
    error = query.get('error')
    if error:
        log.error('Cannot obtain NSoT authentication token due to: %s.', error)
        log.debug('Please verify NSoT URL %s is reachable and email %s is valid', url, email)
        return False
    else:
        log.debug('successfully obtained token from nsot!')
        return query['dict'].get('auth_token')
1035346
def verify(jwsjs):
    """"""
    get_ed25519ll()
    # XXX forbid duplicate keys in JSON input using object_pairs_hook (2.7+)
    recipients = jwsjs["recipients"]
    encoded_payload = binary(jwsjs["payload"])
    headers = []
    for recipient in recipients:
        assertTrue(len(recipient) == 2, "Unknown recipient key {0}".format(recipient))
        h = binary(recipient["header"])
        s = binary(recipient["signature"])
        header = json.loads(native(urlsafe_b64decode(h)))
        assertTrue(header["alg"] == ALG,
                   "Unexpected algorithm {0}".format(header["alg"]))
        if "alg" in header["jwk"] and "kty" not in header["jwk"]:
            header["jwk"]["kty"] = header["jwk"]["alg"]  # b/w for JWK < -08
        assertTrue(header["jwk"]["kty"] == ALG,  # true for Ed25519
                   "Unexpected key type {0}".format(header["jwk"]["kty"]))
        vk = urlsafe_b64decode(binary(header["jwk"]["vk"]))
        secured_input = b".".join((h, encoded_payload))
        sig = urlsafe_b64decode(s)
        sig_msg = sig+secured_input
        verified_input = native(ed25519ll.crypto_sign_open(sig_msg, vk))
        verified_header, verified_payload = verified_input.split('.')
        verified_header = binary(verified_header)
        decoded_header = native(urlsafe_b64decode(verified_header))
        headers.append(json.loads(decoded_header))

    verified_payload = binary(verified_payload)

    # only return header, payload that have passed through the crypto library.
    payload = json.loads(native(urlsafe_b64decode(verified_payload)))

    return headers, payload
881696
function verify(token, privateKey, audience) {
        var deferred = Q.defer();
        var options = { ignoreExpiration: true, audience: audience };

        // no token so return nothing
        if (!token) {
            return new Q();
        }

        jsonwebtoken.verify(token, privateKey, options, function (err, decodedToken) {
            err ? deferred.reject(err) : deferred.resolve(decodedToken);
        });

        return deferred.promise;
    }
126489
function getKey(key, masterPassword) {
    var contents = getContents(masterPassword);
    if (contents[key] != undefined) return contents[key];
    else throw new Error(`Unable to find key '${key}' in password safe.`);
}
647432
private function extractAuthKeyFromPemContent()
    {
        $details = openssl_pkey_get_details(openssl_pkey_get_private($this->pem));
        if (!array_key_exists('key', $details)) {
            return null;
        }

        // Remove BEGIN RSA PRIVATE KEY / END RSA PRIVATE KEY lines
        $KeyStr = trim($details['key']);
        // Support line break on *nix systems, OS, older OS, and Microsoft
        $keyArr = preg_split('/\r\n|\r|\n/', $KeyStr);
        if (strpos($KeyStr, 'BEGIN') !== false) {
            array_shift($keyArr);
            array_pop($keyArr);
        }
        $authKey = implode('', $keyArr);

        // Check auth key is not empty
        if (empty($authKey)) {
            throw new RequestException('Could not retrieve Auth key from PEM content.', 401);
        }

        return $authKey;
    }
160972
def verify(self, token, verifying_key_or_keys, num_required=None):
        
        if not isinstance(verifying_key_or_keys, (list, str, unicode)):
            raise ValueError("Invalid verifying key(s): expected list or string")

        if isinstance(verifying_key_or_keys, list):
            return self._verify_multi(token, verifying_key_or_keys, num_required=num_required)

        else:
            return self._verify_single(token, str(verifying_key_or_keys))
8727
function getAction(key) {
    const keyString = key.toString();

    if (keyString.match(/CERTIFICATE\sREQUEST-{5}$/m)) {
        return 'req';
    }
    else if (keyString.match(/(PUBLIC|PRIVATE)\sKEY-{5}$/m)) {
        return 'rsa';
    }

    return 'x509';
}
12553
private static boolean verifySignature(String content, String secret, String signature) throws InvalidTokenException{
        try {
            SecretKey secretKey = new SecretKeySpec(secret.getBytes(), ALG_HMACSHA256);
            Mac mac = Mac.getInstance(ALG_HMACSHA256);
            mac.init(secretKey);
            byte[] bytes = mac.doFinal(content.getBytes());
            String base64 = base64UrlEncode(bytes);
            return  Strings.equals(base64,signature);
        } catch (Exception e) {
            throw new RuntimeException("Verify signature error", e);
        }
    }