Skip to content

Commit

Permalink
Generated using ./scripts/tools/zap_regen_all.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarcosb committed Nov 14, 2024
1 parent f4c2202 commit a23e0b5
Show file tree
Hide file tree
Showing 5 changed files with 1,692 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package chip.devicecontroller.cluster.structs

import chip.devicecontroller.cluster.*
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class TlsCertificateManagementClusterTLSCertStruct(val caid: UInt, val certificate: ByteArray) {
override fun toString(): String = buildString {
append("TlsCertificateManagementClusterTLSCertStruct {\n")
append("\tcaid : $caid\n")
append("\tcertificate : $certificate\n")
append("}\n")
}

fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
tlvWriter.apply {
startStructure(tlvTag)
put(ContextSpecificTag(TAG_CAID), caid)
put(ContextSpecificTag(TAG_CERTIFICATE), certificate)
endStructure()
}
}

companion object {
private const val TAG_CAID = 0
private const val TAG_CERTIFICATE = 1

fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TlsCertificateManagementClusterTLSCertStruct {
tlvReader.enterStructure(tlvTag)
val caid = tlvReader.getUInt(ContextSpecificTag(TAG_CAID))
val certificate = tlvReader.getByteArray(ContextSpecificTag(TAG_CERTIFICATE))

tlvReader.exitContainer()

return TlsCertificateManagementClusterTLSCertStruct(caid, certificate)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package chip.devicecontroller.cluster.structs

import chip.devicecontroller.cluster.*
import matter.tlv.AnonymousTag
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class TlsCertificateManagementClusterTLSClientCertificateDetailStruct(
val ccdid: UInt,
val clientCertificate: ByteArray,
val intermediateCerts: List<ByteArray>,
) {
override fun toString(): String = buildString {
append("TlsCertificateManagementClusterTLSClientCertificateDetailStruct {\n")
append("\tccdid : $ccdid\n")
append("\tclientCertificate : $clientCertificate\n")
append("\tintermediateCerts : $intermediateCerts\n")
append("}\n")
}

fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
tlvWriter.apply {
startStructure(tlvTag)
put(ContextSpecificTag(TAG_CCDID), ccdid)
put(ContextSpecificTag(TAG_CLIENT_CERTIFICATE), clientCertificate)
startArray(ContextSpecificTag(TAG_INTERMEDIATE_CERTS))
for (item in intermediateCerts.iterator()) {
put(AnonymousTag, item)
}
endArray()
endStructure()
}
}

companion object {
private const val TAG_CCDID = 0
private const val TAG_CLIENT_CERTIFICATE = 1
private const val TAG_INTERMEDIATE_CERTS = 2

fun fromTlv(
tlvTag: Tag,
tlvReader: TlvReader,
): TlsCertificateManagementClusterTLSClientCertificateDetailStruct {
tlvReader.enterStructure(tlvTag)
val ccdid = tlvReader.getUInt(ContextSpecificTag(TAG_CCDID))
val clientCertificate = tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_CERTIFICATE))
val intermediateCerts =
buildList<ByteArray> {
tlvReader.enterArray(ContextSpecificTag(TAG_INTERMEDIATE_CERTS))
while (!tlvReader.isEndOfContainer()) {
add(tlvReader.getByteArray(AnonymousTag))
}
tlvReader.exitContainer()
}

tlvReader.exitContainer()

return TlsCertificateManagementClusterTLSClientCertificateDetailStruct(
ccdid,
clientCertificate,
intermediateCerts,
)
}
}
}
Loading

0 comments on commit a23e0b5

Please sign in to comment.