public void TmaDataReaderOnSampleArrived(LucidDream_DataTypesManaged.idl_idde_itfmod_to_3pa_system_target_data.idde_itfmod_to_3pa_system_target_data_typeDataReader dr, LucidDream_DataTypesManaged.idl_idde_itfmod_to_3pa_system_target_data.idde_itfmod_to_3pa_system_target_data_type dataType, SampleInfo info, ValidityStatus validity) { Console.WriteLine("a new sample of \"idde_itfmod_to_3pa_system_target_data_type\" has arrived"); }
public void OwnBoatReaderOnSampleArrived(LucidDream_DataTypesManaged.idl_idde_itfmod_to_3pa_own_boat_data.idde_itfmod_to_3pa_own_boat_data_typeDataReader dr, LucidDream_DataTypesManaged.idl_idde_itfmod_to_3pa_own_boat_data.idde_itfmod_to_3pa_own_boat_data_type dataType, SampleInfo info, ValidityStatus validity) { OwnBoat_OriginalMessage converted_data = ConvertData(dataType); string data = JsonConvert.SerializeObject(converted_data); rabbit.SendData(data); Console.WriteLine("a new sample of \"idde_itfmod_to_3pa_own_boat_data_type\" has arrived"); }
/// <summary> /// Creates a new CertifiedUserID /// </summary> /// <remarks>No remarks</remarks> public CertifiedUserID() { alCertificates = new ArrayList(); this.validitystatus = ValidityStatus.NotYetValidated; }
/// <summary> /// Validates all certificates belonging the the given public key packet /// and the current certifications. /// </summary> /// <remarks> /// So far only works with v4 signatures! /// </remarks> /// <param name="pkpKey">The public key packet to which the userid /// belongs.</param> /// <param name="pkrRing">A keyring containing all public keys known to /// the system. This is neccessary in order to verify the signatures. /// </param> public void Validate(PublicKeyPacket pkpKey, PublicKeyRing pkrRing) { IEnumerator ieCertificates = Certificates.GetEnumerator(); this.validitystatus = ValidityStatus.Valid; while (ieCertificates.MoveNext()) { if (ieCertificates.Current is SignaturePacket) { SignaturePacket spCert = (SignaturePacket)ieCertificates.Current; TransportablePublicKey tkpSigningKey = pkrRing.Find(spCert.KeyID, true); if (tkpSigningKey == null) { this.validitystatus = ValidityStatus.ValidationKeyUnavailable; continue; } PublicKeyPacket pkpSigningKey = tkpSigningKey.PrimaryKey; if (spCert.Version == SignaturePacketVersionNumbers.v4) { byte[] bKey = new byte[pkpKey.Body.Length + 3]; bKey[0] = 0x99; bKey[1] = (byte)((pkpKey.Body.Length >> 8) & 0xFF); bKey[2] = (byte)(pkpKey.Body.Length & 0xFF); Array.Copy(pkpKey.Body, 0, bKey, 3, pkpKey.Body.Length); byte[] bUserID = new byte[UserID.Body.Length + 5]; bUserID[0] = 0xb4; bUserID[1] = (byte)((UserID.Body.Length >> 24) & 0xFF); bUserID[2] = (byte)((UserID.Body.Length >> 16) & 0xFF); bUserID[3] = (byte)((UserID.Body.Length >> 8) & 0xFF); bUserID[4] = (byte)(UserID.Body.Length & 0xFF); Array.Copy(UserID.Body, 0, bUserID, 5, UserID.Body.Length); byte[] bData = new byte[bUserID.Length + bKey.Length]; Array.Copy(bKey, 0, bData, 0, bKey.Length); Array.Copy(bUserID, 0, bData, bKey.Length, bUserID.Length); spCert.Verify(bData, pkpSigningKey); if(spCert.SignatureStatus == SignatureStatusTypes.Invalid) { this.validitystatus = ValidityStatus.Invalid; continue; } else if(spCert.SignatureStatus == SignatureStatusTypes.Signing_Key_Not_Available) { this.validitystatus = ValidityStatus.ValidationKeyUnavailable; continue; } else if(spCert.SignatureStatus == SignatureStatusTypes.Not_Verified) { this.validitystatus = ValidityStatus.NotYetValidated; continue; } } else { //TODO: Add code for v3 Signature verification } } } }
/// <summary> /// Validates all certificates belonging the the given public key packet /// and the current certifications. /// </summary> /// <remarks> /// So far only works with v4 signatures! /// </remarks> /// <param name="pkpKey">The public key packet to which the userid /// belongs.</param> /// <param name="pkrRing">A keyring containing all public keys known to /// the system. This is neccessary in order to verify the signatures. /// </param> public void Validate(PublicKeyPacket pkpKey, PublicKeyRing pkrRing) { IEnumerator ieCertificates = Certificates.GetEnumerator(); this.validitystatus = ValidityStatus.Valid; while (ieCertificates.MoveNext()) { if (ieCertificates.Current is SignaturePacket) { SignaturePacket spCert = (SignaturePacket)ieCertificates.Current; TransportablePublicKey tkpSigningKey = pkrRing.Find(spCert.KeyID, true); if (tkpSigningKey == null) { this.validitystatus = ValidityStatus.ValidationKeyUnavailable; continue; } PublicKeyPacket pkpSigningKey = tkpSigningKey.PrimaryKey; if (spCert.Version == SignaturePacketVersionNumbers.v4) { byte[] bKey = new byte[pkpKey.Body.Length + 3]; bKey[0] = 0x99; bKey[1] = (byte)((pkpKey.Body.Length >> 8) & 0xFF); bKey[2] = (byte)(pkpKey.Body.Length & 0xFF); Array.Copy(pkpKey.Body, 0, bKey, 3, pkpKey.Body.Length); byte[] bUserID = new byte[UserID.Body.Length + 5]; bUserID[0] = 0xb4; bUserID[1] = (byte)((UserID.Body.Length >> 24) & 0xFF); bUserID[2] = (byte)((UserID.Body.Length >> 16) & 0xFF); bUserID[3] = (byte)((UserID.Body.Length >> 8) & 0xFF); bUserID[4] = (byte)(UserID.Body.Length & 0xFF); Array.Copy(UserID.Body, 0, bUserID, 5, UserID.Body.Length); byte[] bData = new byte[bUserID.Length + bKey.Length]; Array.Copy(bKey, 0, bData, 0, bKey.Length); Array.Copy(bUserID, 0, bData, bKey.Length, bUserID.Length); spCert.Verify(bData, pkpSigningKey); if (spCert.SignatureStatus == SignatureStatusTypes.Invalid) { this.validitystatus = ValidityStatus.Invalid; continue; } else if (spCert.SignatureStatus == SignatureStatusTypes.Signing_Key_Not_Available) { this.validitystatus = ValidityStatus.ValidationKeyUnavailable; continue; } else if (spCert.SignatureStatus == SignatureStatusTypes.Not_Verified) { this.validitystatus = ValidityStatus.NotYetValidated; continue; } } else { //TODO: Add code for v3 Signature verification } } } }