Skip to content

Commit 1bf33d3

Browse files
committed
remove logging calls from development.
1 parent e91b69b commit 1bf33d3

2 files changed

Lines changed: 2 additions & 81 deletions

File tree

src/Kp2aPasskey.Core/AuthenticatorResponses.cs

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,6 @@ private byte[] BuildAuthData()
236236
attestedCredentialData: true
237237
);
238238

239-
// Log for debugging
240-
Log.Debug("AuthenticatorAttestationResponse",
241-
$"Base authData length: {authData.Length}, RP ID: {requestOptions.RelyingPartyEntity.Id}");
242-
Log.Debug("AuthenticatorAttestationResponse",
243-
$"AAGUID length: {AaGuid1.Length}, CredentialId length: {credentialId.Length}");
244-
Log.Debug("AuthenticatorAttestationResponse",
245-
$"CredentialPublicKey length: {credentialPublicKey.Length}");
246-
Log.Debug("AuthenticatorAttestationResponse",
247-
$"CredentialPublicKey CBOR hex: {BitConverter.ToString(credentialPublicKey)}");
248-
249239
// Append AAGUID + credIdLen + credentialId + credentialPublicKey
250240
var credIdLen = new[]
251241
{
@@ -260,9 +250,6 @@ private byte[] BuildAuthData()
260250
.Concat(credentialPublicKey)
261251
.ToArray();
262252

263-
Log.Debug("AuthenticatorAttestationResponse",
264-
$"Final authData length: {result.Length}");
265-
266253
return result;
267254
}
268255

@@ -282,16 +269,6 @@ public JSONObject ToJson()
282269
var authData = BuildAuthData();
283270
var attestationObject = BuildAttestationObject();
284271

285-
// Log hex bytes for debugging - FULL dumps for comparison with KeePassDX
286-
Log.Debug("AuthenticatorAttestationResponse",
287-
$"=== FULL AuthData ({authData.Length} bytes) ===");
288-
Log.Debug("AuthenticatorAttestationResponse",
289-
BitConverter.ToString(authData));
290-
Log.Debug("AuthenticatorAttestationResponse",
291-
$"=== FULL AttestationObject ({attestationObject.Length} bytes) ===");
292-
Log.Debug("AuthenticatorAttestationResponse",
293-
BitConverter.ToString(attestationObject));
294-
295272
var json = new JSONObject();
296273
json.Put("clientDataJSON", clientDataResponse.BuildResponse());
297274
json.Put("authenticatorData", Base64EncodeUrlSafe(authData));
@@ -357,10 +334,6 @@ IClientDataResponse clientDataResponse
357334
{
358335
_userHandle = userHandle;
359336

360-
Log.Debug("AuthenticatorAssertionResponse", "=== AUTHENTICATION DEBUG ===");
361-
Log.Debug("AuthenticatorAssertionResponse", $"RP ID: {requestOptions.RpId}");
362-
Log.Debug("AuthenticatorAssertionResponse", $"Challenge (base64): {Base64.EncodeToString(requestOptions.Challenge, Base64Flags.UrlSafe | Base64Flags.NoPadding | Base64Flags.NoWrap)}");
363-
364337
_authenticatorData = AuthenticatorDataBuilder.BuildAuthenticatorData(
365338
relyingPartyId: Encoding.UTF8.GetBytes(requestOptions.RpId),
366339
userPresent: userPresent,
@@ -369,18 +342,11 @@ IClientDataResponse clientDataResponse
369342
backupState: backupState
370343
);
371344

372-
Log.Debug("AuthenticatorAssertionResponse", $"AuthenticatorData ({_authenticatorData.Length} bytes): {BitConverter.ToString(_authenticatorData)}");
373-
374345
var clientDataHash = clientDataResponse.HashData();
375-
Log.Debug("AuthenticatorAssertionResponse", $"ClientDataHash ({clientDataHash.Length} bytes): {BitConverter.ToString(clientDataHash)}");
376-
Log.Debug("AuthenticatorAssertionResponse", $"ClientDataJSON: {Encoding.UTF8.GetString(Base64.Decode(clientDataResponse.BuildResponse(), Base64Flags.UrlSafe | Base64Flags.NoPadding))}");
377346

378347
// Sign: authenticatorData || clientDataHash
379348
var dataToSign = _authenticatorData.Concat(clientDataHash).ToArray();
380-
Log.Debug("AuthenticatorAssertionResponse", $"DataToSign ({dataToSign.Length} bytes): {BitConverter.ToString(dataToSign)}");
381-
382349
_signature = PasskeyCryptoHelper.Sign(privateKeyPem, dataToSign);
383-
Log.Debug("AuthenticatorAssertionResponse", $"Signature ({_signature.Length} bytes): {BitConverter.ToString(_signature)}");
384350
}
385351

386352
public JSONObject ToJson(IClientDataResponse clientDataResponse)
@@ -395,12 +361,6 @@ public JSONObject ToJson(IClientDataResponse clientDataResponse)
395361
json.Put("signature", signatureB64);
396362
json.Put("userHandle", _userHandle);
397363

398-
Log.Debug("AuthenticatorAssertionResponse", "=== RESPONSE JSON FIELDS ===");
399-
Log.Debug("AuthenticatorAssertionResponse", $"clientDataJSON: {clientDataJson}");
400-
Log.Debug("AuthenticatorAssertionResponse", $"authenticatorData (base64): {authenticatorDataB64}");
401-
Log.Debug("AuthenticatorAssertionResponse", $"signature (base64): {signatureB64}");
402-
Log.Debug("AuthenticatorAssertionResponse", $"userHandle: {_userHandle}");
403-
404364
return json;
405365
}
406366

@@ -425,24 +385,7 @@ public string ToJson()
425385
json.Put("authenticatorAttachment", authenticatorAttachment);
426386
json.Put("response", response);
427387

428-
429-
var jsonString = json.ToString();
430-
Log.Debug("FidoPublicKeyCredential", "=== COMPLETE CREDENTIAL JSON ===");
431-
Log.Debug("FidoPublicKeyCredential", $"id: {id}");
432-
Log.Debug("FidoPublicKeyCredential", $"rawId: {id}");
433-
Log.Debug("FidoPublicKeyCredential", $"type: public-key");
434-
Log.Debug("FidoPublicKeyCredential", $"authenticatorAttachment: {authenticatorAttachment}");
435-
Log.Debug("FidoPublicKeyCredential", $"Full JSON length: {jsonString.Length}");
436-
437-
// Log JSON in chunks to avoid truncation
438-
const int chunkSize = 200;
439-
for (int i = 0; i < jsonString.Length; i += chunkSize)
440-
{
441-
int length = Math.Min(chunkSize, jsonString.Length - i);
442-
Log.Debug("FidoPublicKeyCredential", $"Complete JSON chunk {i / chunkSize}: {jsonString.Substring(i, length)}");
443-
}
444-
445-
return jsonString;
388+
return json.ToString();
446389
}
447390
}
448391
}

src/Kp2aPasskey.Core/PasskeyCryptoHelper.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -101,36 +101,25 @@ public static (AndroidKeyPair keyPair, long algorithmId)? GenerateKeyPair(IEnume
101101
{
102102
var keyPair = GenerateEd25519KeyPair();
103103
if (keyPair != null)
104-
{
105-
Log.Debug("PasskeyCryptoHelper", $"Generated Ed25519 key pair (algorithm {algorithmId})");
106104
return (keyPair, CoseAlgEd25519);
107-
}
108105
break;
109106
}
110107
case CoseAlgEs256:
111108
{
112109
var keyPair = GenerateEs256KeyPair();
113110
if (keyPair != null)
114-
{
115-
Log.Debug("PasskeyCryptoHelper", $"Generated ES256 key pair (algorithm {algorithmId})");
116111
return (keyPair, CoseAlgEs256);
117-
}
118112
break;
119113
}
120114
case CoseAlgRs256:
121115
{
122116
var keyPair = GenerateRs256KeyPair();
123117
if (keyPair != null)
124-
{
125-
Log.Debug("PasskeyCryptoHelper", $"Generated RS256 key pair (algorithm {algorithmId})");
126118
return (keyPair, CoseAlgRs256);
127-
}
128119
break;
129120
}
130121
default:
131-
// Unsupported algorithm, try next one
132-
Log.Debug("PasskeyCryptoHelper", $"Unsupported algorithm {algorithmId}, skipping");
133-
break;
122+
break; // Unsupported algorithm, try next one
134123
}
135124
}
136125

@@ -186,11 +175,7 @@ public static (AndroidKeyPair keyPair, long algorithmId)? GenerateKeyPair(IEnume
186175
{
187176
try
188177
{
189-
Log.Debug("PasskeyCryptoHelper", $"Attempting to generate Ed25519 key pair on Android {Android.OS.Build.VERSION.SdkInt} (API {(int)Android.OS.Build.VERSION.SdkInt})");
190-
191178
// Android's Ed25519 KeyPairGenerator requires Keystore, so we use BouncyCastle C# API
192-
Log.Debug("PasskeyCryptoHelper", "Using BouncyCastle C# API to generate Ed25519 key pair");
193-
194179
var keyPairGenerator = new Ed25519KeyPairGenerator();
195180
keyPairGenerator.Init(new Ed25519KeyGenerationParameters(new Org.BouncyCastle.Security.SecureRandom()));
196181

@@ -208,14 +193,11 @@ public static (AndroidKeyPair keyPair, long algorithmId)? GenerateKeyPair(IEnume
208193
var publicKeyInfo = Org.BouncyCastle.X509.SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKeyParams);
209194
var publicKeyBytes = publicKeyInfo.GetEncoded();
210195

211-
Log.Debug("PasskeyCryptoHelper", $"Generated Ed25519 keys - Private: {privateKeyBytes.Length} bytes, Public: {publicKeyBytes.Length} bytes");
212-
213196
// Create wrapper keys that implement Java interfaces
214197
var privateKey = new Ed25519PrivateKeyWrapper(privateKeyBytes);
215198
var publicKey = new Ed25519PublicKeyWrapper(publicKeyBytes);
216199

217200
var keyPair = new AndroidKeyPair(publicKey, privateKey);
218-
Log.Debug("PasskeyCryptoHelper", $"Ed25519 key pair wrapped successfully. Public key algorithm: {keyPair.Public?.Algorithm}, Format: {keyPair.Public?.Format}");
219201
return keyPair;
220202
}
221203
catch (Exception ex)
@@ -277,15 +259,11 @@ public static byte[] Sign(string privateKeyPem, byte[] dataToSign)
277259
_ => throw new SecurityException($"Unknown key type: {privateKeyParams.GetType().Name}")
278260
};
279261

280-
Log.Debug("PasskeyCryptoHelper", $"Signing with {algorithmSignature} (key type: {privateKeyParams.GetType().Name})");
281-
282262
// Sign using BouncyCastle C# API
283263
var signer = SignerUtilities.GetSigner(algorithmSignature);
284264
signer.Init(true, privateKeyParams);
285265
signer.BlockUpdate(dataToSign, 0, dataToSign.Length);
286266
var signatureBytes = signer.GenerateSignature();
287-
288-
Log.Debug("PasskeyCryptoHelper", $"Signed {dataToSign.Length} bytes → {signatureBytes.Length} byte signature");
289267
return signatureBytes;
290268
}
291269
catch (Exception ex)

0 commit comments

Comments
 (0)