From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.182.162 with SMTP id ef2mr20648691pac.40.1398099263457; Mon, 21 Apr 2014 09:54:23 -0700 (PDT) Path: backlog4.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!c1no1582665igq.0!news-out.google.com!dz10ni16774qab.1!nntp.google.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx14.iad.POSTED!not-for-mail Message-ID: <53554D3F.8050009@shaw.ca> From: Brad Moore User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Type Transcriptions References: In-Reply-To: NNTP-Posting-Host: 68.145.219.148 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: 1398099263 68.145.219.148 (Mon, 21 Apr 2014 16:54:23 UTC) NNTP-Posting-Date: Mon, 21 Apr 2014 16:54:23 UTC Date: Mon, 21 Apr 2014 10:54:23 -0600 X-Received-Bytes: 2813 X-Received-Body-CRC: 2402107405 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Original-Bytes: 2731 Xref: number.nntp.dca.giganews.com comp.lang.ada:185910 Date: 2014-04-21T10:54:23-06:00 List-Id: On 14-04-21 01:21 AM, Shark8 wrote: > I recently started a little project intended to implement TLS 1.2 in Ada > 2012 and SPARK; reading through the RFC and transcribing the types has > been relatively straightforward. > > However there is one hiccup; a certain class of record-type is dependent > on the values in another record, yet distinctly separate; ex: > > > struct { > opaque nonce_explicit[SecurityParameters.record_iv_length]; > aead-ciphered struct { > opaque content[TLSCompressed.length]; > }; > } GenericAEADCipher; > > where SecurityParameters is > > struct { > ConnectionEnd entity; > PRFAlgorithm prf_algorithm; > BulkCipherAlgorithm bulk_cipher_algorithm; > CipherType cipher_type; > uint8 enc_key_length; > uint8 block_length; > uint8 fixed_iv_length; > uint8 record_iv_length; > MACAlgorithm mac_algorithm; > uint8 mac_length; > uint8 mac_key_length; > CompressionMethod compression_algorithm; > opaque master_secret[48]; > opaque client_random[32]; > opaque server_random[32]; > } SecurityParameters; > > Now I've already transcribed the SecurityParameters parameters record, > but it seems to me that since these other types are dependent on the > SecurityParameters, I could change it into a generic package with the > record's current components being input parameters. > > Any advice on which route to take would be greatly appreciated. I'd suggest trying to make GenericAEADCipher a discriminated record type, with the two length values as the discriminants, and then the arrays are sized using the discriminants. No Generics needed. Brad