Skip to content

Instantly share code, notes, and snippets.

@schirrmacher
schirrmacher / GoogleSafetyNetAttestationService.ts
Last active June 14, 2023 09:53
SafetyNet Attestation Backend Example Implementation for Validating Android Device Authenticity
import moment = require("moment");
import config from "../../../config";
import BaseService from "../BaseService";
import { DeviceCheckService, DeviceCheckParams } from "./DeviceCheckService";
import { buildQueryParams } from "../helper/QueryHelper";
import { isSuccessStatus } from "../helper/ResponseHelper";
import { isTokenReplayed } from "../helper/DatabaseHelper";
@schirrmacher
schirrmacher / DeviceCheckCoordinator.ts
Last active May 27, 2021 13:17
Backend Implementation of Apple's DeviceCheck and Google's SafetyNet Attestation API
import BaseService from "./BaseService";
import BaseCoordinator from "./BaseCoordinator";
import { DeviceCheckParams, DeviceCheckService } from "./DeviceCheckService";
import { GoogleSafetyNetAttestationService } from "./GoogleSafetyNetAttestationService";
import { AppleDeviceCheckService } from "./AppleDeviceCheckService";
import * as UserAgentParser from "../helper/UserAgentParser";
export default class DeviceCheckCoordinator extends BaseCoordinator {
@schirrmacher
schirrmacher / SafetyNetAttestation.kt
Created March 6, 2020 15:21
SafetyNet Attestation Example Implementation for Validating Device Authenticity on Android
import android.content.Context
import android.util.Base64
import com.google.android.gms.safetynet.SafetyNet
import inject.AppContext
import inject.modules.GoogleServicesModule.GoogleContext
import io.reactivex.Single
import java.io.ByteArrayOutputStream
import javax.inject.Inject
interface SecurityHelper {
@schirrmacher
schirrmacher / AppleDeviceCheckService.ts
Last active July 9, 2024 20:32
DeviceCheck Backend Example Implementation for Validating iOS Device Authenticity
import jwt from "jsonwebtoken";
import uuid from "uuid";
import config from "../../../config";
import { DeviceCheckService, DeviceCheckParams } from "./DeviceCheckService";
import BaseService from "./BaseService";
export class AppleDeviceCheckService extends BaseService implements DeviceCheckService {
@schirrmacher
schirrmacher / DeviceCheck.swift
Last active March 9, 2020 13:25
DeviceCheck Example Implementation for Validating Device Authenticity on iOS
import Foundation
import RxSwift
import DeviceCheck
public struct Client {
private static func retrieveDeviceToken() -> Observable<String?> {
if #available(iOS 11.0, *) {
return Observable.create({ observer -> Disposable in
guard DCDevice.current.isSupported else {
static srtp_err_status_t srtp_hmac_compute(void *statev,
const uint8_t *message,
int msg_octets,
int tag_len,
uint8_t *result)
debug_print(srtp_mod_aes_icm, "key: %s",
srtp_octet_string_hex_string(key, base_key_len));
debug_print(srtp_mod_aes_icm, "offset: %s", v128_hex_string(&c->offset));
int sub_100bbda00(int arg0, int arg1) {
r31 = r31 - 0x60;
var_30 = r24;
stack[-56] = r23;
var_20 = r22;
stack[-40] = r21;
var_10 = r20;
stack[-24] = r19;
saved_fp = r29;
stack[-8] = r30;
int signal_encrypt(signal_context *context,
signal_buffer **output,
int cipher,
const uint8_t *key, size_t key_len,
const uint8_t *iv, size_t iv_len,
const uint8_t *plaintext, size_t plaintext_len);
@schirrmacher
schirrmacher / WAHKDF.deriveSecretsFromInputKeyMaterial.js
Created February 4, 2020 08:52
Log deriveSecretsFromInputKeyMaterial params
{
onEnter: function (log, args, state) {
log("+[ WAHKDF deriveSecretsFromInputKeyMaterial: " +
ObjC.Object( args[2] ).toString() + "\n" +
" salt: " + ObjC.Object( args[3] ).toString() + "\n" +
" info: " + ObjC.Object( args[4] ).toString() + "\n" +
" bytes : " + args[5].toInt32 () + "\n" +
" withMessageVersion : " + args[6].toInt32 () + "\n]");
}
}